adjust not-command to use methods instead.
This commit is contained in:
parent
a6c80b45a4
commit
ac5c8e9fa0
2 changed files with 8 additions and 13 deletions
|
@ -4,7 +4,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace Bot.NonCommands
|
namespace Bot.NonCommands
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
public class NotCommand : Attribute
|
public class NotCommand : Attribute
|
||||||
{
|
{
|
||||||
public NotCommand()
|
public NotCommand()
|
||||||
|
|
|
@ -17,27 +17,21 @@ namespace Bot.NonCommands
|
||||||
{
|
{
|
||||||
foreach(Type t in a.GetTypes())
|
foreach(Type t in a.GetTypes())
|
||||||
{
|
{
|
||||||
if (t.IsClass)
|
if (t.IsClass && t!=null)
|
||||||
{
|
{
|
||||||
try
|
foreach (MethodInfo mi in t.GetMethods())
|
||||||
{
|
{
|
||||||
|
NotCommand[] nc = (NotCommand[])mi.GetCustomAttributes(typeof(NotCommand), false);
|
||||||
foreach (NotCommand NC in (NotCommand[])t.GetCustomAttributes(false))
|
if (nc.Length>0)
|
||||||
{
|
{
|
||||||
MethodInfo mi = t.GetMethod("handle");
|
|
||||||
|
|
||||||
ThreadStart work = delegate
|
ThreadStart work = delegate
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator });
|
mi.Invoke(Activator.CreateInstance(mi.DeclaringType), new object[] { request, agentKey, agentName, sourceLoc, originator });
|
||||||
};
|
};
|
||||||
Thread T = new Thread(work);
|
Thread T = new Thread(work);
|
||||||
|
|
||||||
|
|
||||||
// _mi.Invoke(Activator.CreateInstance(_mi.DeclaringType), new object[] { });
|
|
||||||
T.Start();
|
T.Start();
|
||||||
}
|
|
||||||
}catch(Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +39,5 @@ namespace Bot.NonCommands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue