PowerToys/Wox/PluginLoader/BasePluginLoader.cs
2014-07-07 23:05:06 +08:00

33 lines
1001 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wox.Plugin;
using Wox.RPC;
namespace Wox.PluginLoader
{
public class BasePluginLoader<T> : IPluginLoader where T : BasePluginWrapper, new()
{
public virtual 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;
}
}
}