PowerToys/Wox/PluginLoader/BasePluginLoader.cs

24 lines
718 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
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
{
2014-07-11 18:36:39 +08:00
string supportedLanguage = new T().SupportedLanguage;
List<PluginMetadata> metadatas = pluginMetadatas.Where(o => supportedLanguage.ToUpper() == o.Language.ToUpper()).ToList();
2014-07-06 22:57:11 +08:00
2014-07-09 23:44:57 +08:00
return metadatas.Select(metadata => new PluginPair()
{
2014-07-11 18:36:39 +08:00
Plugin = new T(),
2014-07-09 23:44:57 +08:00
Metadata = metadata
}).ToList();
2014-07-06 22:57:11 +08:00
}
}
2013-12-20 19:38:10 +08:00
}