2014-12-26 14:51:04 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-01-03 10:16:05 +00:00
|
|
|
|
using System.Linq;
|
2014-01-03 15:52:36 +00:00
|
|
|
|
using System.Threading;
|
2015-01-16 15:42:12 +00:00
|
|
|
|
using Wox.Core.Exception;
|
2015-01-05 14:41:17 +00:00
|
|
|
|
using Wox.Core.UserSettings;
|
2015-01-16 15:42:12 +00:00
|
|
|
|
using Wox.Infrastructure.Logger;
|
2014-01-29 10:33:24 +00:00
|
|
|
|
using Wox.Plugin;
|
2015-01-03 07:20:34 +00:00
|
|
|
|
//using Wox.Plugin.SystemPlugins;
|
2014-01-03 10:16:05 +00:00
|
|
|
|
|
2014-12-26 14:51:04 +00:00
|
|
|
|
namespace Wox.Core.Plugin.QueryDispatcher
|
2014-01-03 10:16:05 +00:00
|
|
|
|
{
|
2014-12-26 14:51:04 +00:00
|
|
|
|
public class SystemPluginQueryDispatcher : IQueryDispatcher
|
2014-01-03 10:16:05 +00:00
|
|
|
|
{
|
2015-01-04 15:08:26 +00:00
|
|
|
|
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => PluginManager.IsSystemPlugin(o.Metadata));
|
2014-10-22 14:49:34 +00:00
|
|
|
|
|
2014-12-26 14:51:04 +00:00
|
|
|
|
public void Dispatch(Query query)
|
2014-01-03 10:16:05 +00:00
|
|
|
|
{
|
2014-10-23 10:39:11 +00:00
|
|
|
|
var queryPlugins = allSytemPlugins;
|
|
|
|
|
|
foreach (PluginPair pair in queryPlugins)
|
2014-07-21 15:18:39 +00:00
|
|
|
|
{
|
|
|
|
|
|
PluginPair pair1 = pair;
|
2014-01-03 15:52:36 +00:00
|
|
|
|
ThreadPool.QueueUserWorkItem(state =>
|
|
|
|
|
|
{
|
2015-01-16 15:42:12 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
List<Result> results = pair1.Plugin.Query(query);
|
|
|
|
|
|
results.ForEach(o => { o.AutoAjustScore = true; });
|
2014-07-05 15:10:34 +00:00
|
|
|
|
|
2015-01-16 15:42:12 +00:00
|
|
|
|
PluginManager.API.PushResults(query, pair1.Metadata, results);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (System.Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new WoxPluginException(pair1.Metadata.Name,e);
|
|
|
|
|
|
}
|
2014-01-03 15:52:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2014-01-03 10:16:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-01-04 15:08:26 +00:00
|
|
|
|
}
|