PowerToys/Wox/PluginLoader/BasePluginLoader.cs

33 lines
994 B
C#
Raw Normal View History

2013-12-20 19:38:10 +08:00
using System;
using System.Collections.Generic;
2014-01-03 18:16:05 +08:00
using System.Linq;
2014-07-06 22:57:11 +08:00
using System.Text;
2014-01-29 18:33:24 +08:00
using Wox.Plugin;
2014-07-06 22:57:11 +08:00
using Wox.RPC;
namespace Wox.PluginLoader
{
2014-07-09 18:15:23 +08:00
public class BasePluginLoader<T> : IPluginLoader where T : BasePlugin, new()
2014-07-06 22:57:11 +08:00
{
2014-07-07 23:05:06 +08:00
public virtual List<PluginPair> LoadPlugin(List<PluginMetadata> pluginMetadatas)
2014-07-06 22:57:11 +08:00
{
List<PluginPair> plugins = new List<PluginPair>();
T pluginWrapper = new T();
List<string> allowedLanguages = pluginWrapper.GetAllowedLanguages();
List<PluginMetadata> metadatas = pluginMetadatas.Where(o => allowedLanguages.Contains(o.Language.ToUpper())).ToList();
foreach (PluginMetadata metadata in metadatas)
{
PluginPair pair = new PluginPair()
{
Plugin = pluginWrapper,
Metadata = metadata
};
plugins.Add(pair);
}
return plugins;
}
}
2013-12-20 19:38:10 +08:00
}