2014-01-03 18:16:05 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2014-01-03 23:52:36 +08:00
|
|
|
|
using System.Threading;
|
2014-01-03 18:16:05 +08:00
|
|
|
|
using WinAlfred.Plugin;
|
2014-01-03 23:52:36 +08:00
|
|
|
|
using WinAlfred.PluginLoader;
|
2014-01-03 18:16:05 +08:00
|
|
|
|
|
|
|
|
|
namespace WinAlfred.Commands
|
|
|
|
|
{
|
2014-01-03 23:52:36 +08:00
|
|
|
|
public class SystemCommand : BaseCommand
|
2014-01-03 18:16:05 +08:00
|
|
|
|
{
|
2014-01-03 23:52:36 +08:00
|
|
|
|
private List<PluginPair> systemPlugins;
|
|
|
|
|
|
|
|
|
|
public SystemCommand(MainWindow window)
|
|
|
|
|
: base(window)
|
|
|
|
|
{
|
|
|
|
|
systemPlugins = Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-13 18:43:44 +08:00
|
|
|
|
public override void Dispatch(Query query,bool updateView)
|
2014-01-03 18:16:05 +08:00
|
|
|
|
{
|
2014-01-03 23:52:36 +08:00
|
|
|
|
foreach (PluginPair pair in systemPlugins)
|
|
|
|
|
{
|
|
|
|
|
PluginPair pair1 = pair;
|
|
|
|
|
ThreadPool.QueueUserWorkItem(state =>
|
|
|
|
|
{
|
|
|
|
|
List<Result> results = pair1.Plugin.Query(query);
|
|
|
|
|
foreach (Result result in results)
|
|
|
|
|
{
|
|
|
|
|
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
|
|
|
|
|
result.OriginQuery = query;
|
2014-01-15 22:45:02 +08:00
|
|
|
|
result.AutoAjustScore = true;
|
2014-01-03 23:52:36 +08:00
|
|
|
|
}
|
2014-01-13 18:43:44 +08:00
|
|
|
|
if(results.Count > 0 && updateView) UpdateResultView(results);
|
2014-01-03 23:52:36 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-01-03 18:16:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|