日期:2014-05-17 浏览次数:21054 次
private bool LoadPlugin()
{
foreach (string fileName in Directory.GetFiles(_PluginPath.ToString()))
{
FileInfo file = new FileInfo(fileName);
if (!file.Extension.Equals(".dll")) continue;
Assembly pluginAssembly = Assembly.LoadFrom(fileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
// Only look at public types and non-abstract types
if (!pluginType.IsPublic || pluginType.IsAbstract)
{
continue;
}
// Get a type object of the interface we need the plugins to match
Type typeInterface = pluginType.GetInterface("XXX.PlugIn.IPlugIn", true);
// Make sure the interface we want to use actually exists
if (typeInterface == null)
{
continue;
}
foreach (PlugInAttribute attribute in pluginType.GetCustomAttributes(typeof(PlugInAttribute), true))
{
&nb