Restructure
This commit is contained in:
parent
437cc0e0e1
commit
da91200c74
16 changed files with 43 additions and 110 deletions
38
PluginActivator.cs
Normal file
38
PluginActivator.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bot
|
||||
{
|
||||
public class PluginActivator
|
||||
{
|
||||
public Assembly LoadedASM = null;
|
||||
public void LoadLibrary(string DLL)
|
||||
{
|
||||
|
||||
LoadedASM = Assembly.LoadFrom(DLL);
|
||||
}
|
||||
|
||||
public List<IProgram> Activate(Assembly asm)
|
||||
{
|
||||
List<IProgram> Plugins = new List<IProgram>();
|
||||
foreach (Type A in asm.GetTypes())
|
||||
{
|
||||
Type check = A.GetInterface("IProgram");
|
||||
if (check == null)
|
||||
{
|
||||
//return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
IProgram plugin = Activator.CreateInstance(A) as IProgram;
|
||||
Plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
return Plugins;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue