PowerToys/Wox/PluginLoader/BasePluginLoader.cs

33 lines
975 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
{
public class BasePluginLoader<T> where T :BasePluginWrapper,new()
{
public List<PluginPair> LoadPlugin(List<PluginMetadata> pluginMetadatas)
{
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
}