mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
First commit to SVN
git-svn-id: svn://claunia.com/FileSystemIDandChk@1 17725271-3d32-4980-a8cb-9ff532f270ba
This commit is contained in:
64
FileSystemIDandChk/Plugins.cs
Normal file
64
FileSystemIDandChk/Plugins.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using FileSystemIDandChk.Plugins;
|
||||
using FileSystemIDandChk.PartPlugins;
|
||||
|
||||
namespace FileSystemIDandChk
|
||||
{
|
||||
public class PluginBase
|
||||
{
|
||||
public Dictionary<string, Plugin> PluginsList;
|
||||
public Dictionary<string, PartPlugin> PartPluginsList;
|
||||
|
||||
public PluginBase ()
|
||||
{
|
||||
this.PluginsList = new Dictionary<string, Plugin>();
|
||||
this.PartPluginsList = new Dictionary<string, PartPlugin>();
|
||||
}
|
||||
|
||||
public void RegisterAllPlugins()
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
foreach (Type type in assembly.GetTypes())
|
||||
{
|
||||
try
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user