Esempio n. 1
0
 internal Commands(HeroesAdminManager _manager)
 {
     this.manager     = _manager;
     this.commandDict = new Dictionary <string, Commands.CommandHandler>();
     MethodInfo[] methods = base.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     foreach (MethodInfo methodInfo in methods)
     {
         object[] customAttributes = methodInfo.GetCustomAttributes(typeof(CommandHandlerAttribute), false);
         if (customAttributes.Length > 0)
         {
             Delegate @delegate = Delegate.CreateDelegate(typeof(Commands.CommandHandler), this, methodInfo, false);
             if (@delegate != null)
             {
                 foreach (CommandHandlerAttribute commandHandlerAttribute in customAttributes)
                 {
                     if (!this.commandDict.ContainsKey(commandHandlerAttribute.Command))
                     {
                         this.commandDict.Add(commandHandlerAttribute.Command, @delegate as Commands.CommandHandler);
                         RCClient.Console_AddCustomCommand(RCProcess.CustomCommandParser.ToRawString(commandHandlerAttribute.Name, commandHandlerAttribute.Command, commandHandlerAttribute.Argument));
                     }
                 }
             }
         }
     }
 }