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
|
|
|
|
{
|
|
|
|
|
T pluginWrapper = new T();
|
2014-07-09 23:44:57 +08:00
|
|
|
|
List<PluginMetadata> metadatas = pluginMetadatas.Where(o => pluginWrapper.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()
|
|
|
|
|
{
|
|
|
|
|
Plugin = pluginWrapper,
|
|
|
|
|
Metadata = metadata
|
|
|
|
|
}).ToList();
|
2014-07-06 22:57:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-20 19:38:10 +08:00
|
|
|
|
}
|