mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Rename the project.
This commit is contained in:
56
Wox/PluginLoader/Plugins.cs
Normal file
56
Wox/PluginLoader/Plugins.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.CSharp;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.PluginLoader
|
||||
{
|
||||
public static class Plugins
|
||||
{
|
||||
private static List<PluginPair> plugins = new List<PluginPair>();
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
plugins.Clear();
|
||||
BasePluginLoader.ParsePluginsConfig();
|
||||
|
||||
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
||||
{
|
||||
IPlugin plugin1 = plugin;
|
||||
PluginPair pluginPair = plugins.FirstOrDefault(o => o.Plugin == plugin1);
|
||||
if (pluginPair != null)
|
||||
{
|
||||
PluginMetadata metadata = pluginPair.Metadata;
|
||||
ThreadPool.QueueUserWorkItem(o => plugin1.Init(new PluginInitContext()
|
||||
{
|
||||
Plugins = plugins,
|
||||
PluginMetadata = metadata,
|
||||
ChangeQuery = s => App.Window.ChangeQuery(s),
|
||||
CloseApp = App.Window.CloseApp,
|
||||
HideApp = App.Window.HideApp,
|
||||
ShowApp = () => App.Window.ShowApp(),
|
||||
ShowMsg = (title, subTitle, iconPath) => App.Window.ShowMsg(title, subTitle, iconPath),
|
||||
OpenSettingDialog = () => App.Window.OpenSettingDialog()
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<PluginPair> AllPlugins
|
||||
{
|
||||
get { return plugins; }
|
||||
}
|
||||
|
||||
public static bool HitThirdpartyKeyword(Query query)
|
||||
{
|
||||
if (string.IsNullOrEmpty(query.ActionName)) return false;
|
||||
|
||||
return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user