mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
Refactoring. Move system plugins to seperate DLLs.
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
//using Wox.Plugin.SystemPlugins;
|
||||
|
||||
namespace Wox.Core.Plugin
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace Wox.Core.Plugin
|
||||
try
|
||||
{
|
||||
Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
|
||||
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && (o.BaseType == typeof(BaseSystemPlugin) || o.GetInterfaces().Contains(typeof(IPlugin)))).ToList();
|
||||
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin))).ToList();
|
||||
if (types.Count == 0)
|
||||
{
|
||||
Log.Warn(string.Format("Couldn't load plugin {0}: didn't find the class that implement IPlugin", metadata.Name));
|
||||
@@ -35,11 +35,11 @@ namespace Wox.Core.Plugin
|
||||
Metadata = metadata
|
||||
};
|
||||
|
||||
var sys = pair.Plugin as BaseSystemPlugin;
|
||||
if (sys != null)
|
||||
{
|
||||
sys.PluginDirectory = metadata.PluginDirectory;
|
||||
}
|
||||
//var sys = pair.Plugin as BaseSystemPlugin;
|
||||
//if (sys != null)
|
||||
//{
|
||||
// sys.PluginDirectory = metadata.PluginDirectory;
|
||||
//}
|
||||
|
||||
plugins.Add(pair);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,9 @@ namespace Wox.Core.Plugin
|
||||
public static List<PluginMetadata> Parse(List<string> pluginDirectories)
|
||||
{
|
||||
pluginMetadatas.Clear();
|
||||
ParseSystemPlugins();
|
||||
foreach (string pluginDirectory in pluginDirectories)
|
||||
{
|
||||
ParseUserPlugins(pluginDirectory);
|
||||
ParsePluginConfigs(pluginDirectory);
|
||||
}
|
||||
|
||||
if (PluginManager.DebuggerMode != null)
|
||||
@@ -39,31 +38,7 @@ namespace Wox.Core.Plugin
|
||||
return pluginMetadatas;
|
||||
}
|
||||
|
||||
private static void ParseSystemPlugins()
|
||||
{
|
||||
string systemPluginPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"Wox.Plugin.SystemPlugins.dll");
|
||||
if (!File.Exists(systemPluginPath))
|
||||
{
|
||||
throw new WoxCritialException("System Plugin DLL is missing.");
|
||||
}
|
||||
|
||||
pluginMetadatas.Add(new PluginMetadata()
|
||||
{
|
||||
Name = "System Plugins",
|
||||
Author = "System",
|
||||
Description = "system plugins collection",
|
||||
Website = "http://www.getwox.com",
|
||||
Language = AllowedLanguage.CSharp,
|
||||
Version = "1.0.0",
|
||||
PluginType = PluginType.System,
|
||||
ActionKeyword = "*",
|
||||
ExecuteFileName = "Wox.Plugin.SystemPlugins.dll",
|
||||
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||
});
|
||||
}
|
||||
|
||||
private static void ParseUserPlugins(string pluginDirectory)
|
||||
private static void ParsePluginConfigs(string pluginDirectory)
|
||||
{
|
||||
if (!Directory.Exists(pluginDirectory)) return;
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
//using Wox.Plugin.SystemPlugins;
|
||||
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
public class SystemPluginQueryDispatcher : IQueryDispatcher
|
||||
{
|
||||
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System);
|
||||
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.ActionKeyword == "*");
|
||||
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
|
||||
5
Wox.Core/Plugin/README.md
Normal file
5
Wox.Core/Plugin/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
There are two kinds of plugins:
|
||||
1. System plugin
|
||||
Those plugins that action keyword is "*", those plugin doesn't need action keyword
|
||||
2. User Plugin
|
||||
Those plugins that contains customized action keyword
|
||||
Reference in New Issue
Block a user