mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 03:37:10 +08:00
33 lines
994 B
C#
33 lines
994 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 : BasePlugin, 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;
|
|
}
|
|
}
|
|
}
|