2011-03-03 18:34:33 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FileSystemIDandChk.Plugins;
|
|
|
|
|
using FileSystemIDandChk.PartPlugins;
|
2013-12-16 01:04:17 +00:00
|
|
|
using FileSystemIDandChk.ImagePlugins;
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
|
|
|
namespace FileSystemIDandChk
|
|
|
|
|
{
|
|
|
|
|
public class PluginBase
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, Plugin> PluginsList;
|
|
|
|
|
public Dictionary<string, PartPlugin> PartPluginsList;
|
2013-12-16 01:04:17 +00:00
|
|
|
public Dictionary<string, ImagePlugin> ImagePluginsList;
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
|
|
|
public PluginBase ()
|
|
|
|
|
{
|
|
|
|
|
this.PluginsList = new Dictionary<string, Plugin>();
|
|
|
|
|
this.PartPluginsList = new Dictionary<string, PartPlugin>();
|
2013-12-16 01:04:17 +00:00
|
|
|
this.ImagePluginsList = new Dictionary<string, ImagePlugin>();
|
2011-03-03 18:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RegisterAllPlugins()
|
|
|
|
|
{
|
|
|
|
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
|
|
|
|
|
foreach (Type type in assembly.GetTypes())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2013-12-16 01:04:17 +00:00
|
|
|
if (type.IsSubclassOf(typeof(ImagePlugin)))
|
|
|
|
|
{
|
|
|
|
|
ImagePlugin plugin = (ImagePlugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this });
|
|
|
|
|
this.RegisterImagePlugin(plugin);
|
|
|
|
|
}
|
2011-03-03 18:34:33 +00:00
|
|
|
if (type.IsSubclassOf(typeof(Plugin)))
|
|
|
|
|
{
|
|
|
|
|
Plugin plugin = (Plugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this });
|
|
|
|
|
this.RegisterPlugin(plugin);
|
|
|
|
|
}
|
|
|
|
|
else if (type.IsSubclassOf(typeof(PartPlugin)))
|
|
|
|
|
{
|
|
|
|
|
PartPlugin partplugin = (PartPlugin)type.GetConstructor(new Type[] { typeof(PluginBase) }).Invoke(new object[] { this });
|
|
|
|
|
this.RegisterPartPlugin(partplugin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(exception.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-16 01:04:17 +00:00
|
|
|
private void RegisterImagePlugin(ImagePlugin plugin)
|
|
|
|
|
{
|
|
|
|
|
if (!this.ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
|
|
|
|
{
|
|
|
|
|
this.ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-03 18:34:33 +00:00
|
|
|
private void RegisterPlugin(Plugin plugin)
|
|
|
|
|
{
|
|
|
|
|
if (!this.PluginsList.ContainsKey(plugin.Name.ToLower()))
|
|
|
|
|
{
|
|
|
|
|
this.PluginsList.Add(plugin.Name.ToLower(), plugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RegisterPartPlugin(PartPlugin partplugin)
|
|
|
|
|
{
|
|
|
|
|
if (!this.PartPluginsList.ContainsKey(partplugin.Name.ToLower()))
|
|
|
|
|
{
|
|
|
|
|
this.PartPluginsList.Add(partplugin.Name.ToLower(), partplugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|