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"); } }
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); } }