diff --git a/NonCommands/NotCommand.cs b/NonCommands/NotCommand.cs index 52ab15f..1ab508e 100644 --- a/NonCommands/NotCommand.cs +++ b/NonCommands/NotCommand.cs @@ -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() diff --git a/NonCommands/nRegistry.cs b/NonCommands/nRegistry.cs index 4519bca..afdd8b9 100644 --- a/NonCommands/nRegistry.cs +++ b/NonCommands/nRegistry.cs @@ -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) - { + } } } }