mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 12:09:18 +08:00
9d9400f4d9
DebugHelper is useless, bacuase the return statement is always executed before the actual code.
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Wox.Core.UserSettings;
|
|
using Wox.Infrastructure;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Core.Plugin.QueryDispatcher
|
|
{
|
|
public abstract class BaseQueryDispatcher : IQueryDispatcher
|
|
{
|
|
protected abstract List<PluginPair> GetPlugins(Query query);
|
|
|
|
public void Dispatch(Query query)
|
|
{
|
|
foreach (PluginPair pair in GetPlugins(query))
|
|
{
|
|
var customizedPluginConfig = UserSettingStorage.Instance.
|
|
CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID);
|
|
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
|
{
|
|
return;
|
|
}
|
|
PluginPair localPair = pair;
|
|
if (query.IsIntantQuery && PluginManager.IsInstantSearchPlugin(pair.Metadata))
|
|
{
|
|
Debug.WriteLine(string.Format("Plugin {0} is executing instant search.", pair.Metadata.Name));
|
|
using (new Timeit(" => instant search took: "))
|
|
{
|
|
PluginManager.ExecutePluginQuery(localPair, query);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ThreadPool.QueueUserWorkItem(state =>
|
|
{
|
|
PluginManager.ExecutePluginQuery(localPair, query);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|