Пример #1
0
 private void Register(GmCommandHandler handler)
 {
     GmAttribute[] attribute = handler.Method.GetCustomAttributes(typeof(GmAttribute), true) as GmAttribute[];
     if (attribute != null && attribute.Length > 0)
     {
         GmCommand command = new GmCommand();
         command.attribute = attribute[0];
         command.handler   = handler;
         string name = attribute[0].Name.ToUpperInvariant();
         CommandList.Add(name, command);
     }
     else
     {
         throw new SystemException("Cannot register command: no information found");
     }
 }
Пример #2
0
 protected void RegisterExternalGmCommand(string path)
 {
     try
     {
         GmCommandHandler handler = CoreService.Find <GmCommandHandler>(path);
         if (handler != null)
         {
             Register(handler);
         }
         else
         {
             HostContext.AddUnhandeldException(new SystemException(string.Format("Cannot find console command: {0}", path)));
         }
     }
     catch (Exception e)
     {
         //do nothing here
         HostContext.AddUnhandeldException(e);
     }
 }
 private void Register(GmCommandHandler handler)
 {
     GmAttribute[] attribute = handler.Method.GetCustomAttributes(typeof(GmAttribute), true) as GmAttribute[];
     if (attribute != null && attribute.Length > 0)
     {
         GmCommand command = new GmCommand();
         command.attribute = attribute[0];
         command.handler = handler;
         string name = attribute[0].Name.ToUpperInvariant();
         CommandList.Add(name, command);
     }
     else
     {
         throw new SystemException("Cannot register command: no information found");
     }
 }