Add bot source

This commit is contained in:
Zontreck 2019-12-19 03:33:30 -07:00
parent 020d43b81c
commit 437cc0e0e1
14 changed files with 1788 additions and 0 deletions

44
Source/PluginActivator.cs Normal file
View file

@ -0,0 +1,44 @@
/*
Copyright © 2019 Tara Piccari (Aria; Tashia Redrose)
Licensed under the AGPL-3.0
*/
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;
}
}
}