adjust not-command to use methods instead.

This commit is contained in:
Zontreck 2020-04-10 16:53:17 -07:00
parent a6c80b45a4
commit ac5c8e9fa0
2 changed files with 8 additions and 13 deletions

View file

@ -4,7 +4,7 @@ using System.Text;
namespace Bot.NonCommands
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class NotCommand : Attribute
{
public NotCommand()

View file

@ -17,28 +17,23 @@ namespace Bot.NonCommands
{
foreach(Type t in a.GetTypes())
{
if (t.IsClass)
if (t.IsClass && t!=null)
{
try
foreach (MethodInfo mi in t.GetMethods())
{
foreach (NotCommand NC in (NotCommand[])t.GetCustomAttributes(false))
NotCommand[] nc = (NotCommand[])mi.GetCustomAttributes(typeof(NotCommand), false);
if (nc.Length>0)
{
MethodInfo mi = t.GetMethod("handle");
ThreadStart work = delegate
{
mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator });
};
Thread T = new Thread(work);
// _mi.Invoke(Activator.CreateInstance(_mi.DeclaringType), new object[] { });
T.Start();
}
}catch(Exception e)
{
}
}
}
}