PowerToys/Wox.Core/AssemblyHelper.cs

28 lines
850 B
C#
Raw Normal View History

2015-02-07 20:17:49 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using Wox.Core.Plugin;
using Wox.Plugin;
namespace Wox.Core
{
internal class AssemblyHelper
{
public static List<KeyValuePair<PluginPair, T>> LoadPluginInterfaces<T>() where T : class
{
List<KeyValuePair<PluginPair, T>> results = new List<KeyValuePair<PluginPair, T>>();
foreach (PluginPair pluginPair in PluginManager.AllPlugins)
2015-02-07 20:17:49 +08:00
{
//need to load types from AllPlugins
//PluginInitContext is only available in this instance
T type = pluginPair.Plugin as T;
if (type != null)
2015-02-07 20:17:49 +08:00
{
results.Add(new KeyValuePair<PluginPair, T>(pluginPair,type));
2015-02-07 20:17:49 +08:00
}
}
return results;
2015-02-07 20:17:49 +08:00
}
}
}