/// <summary> /// Executes this command. /// </summary> /// <param name="context">The processing context</param> /// <returns>True if the command executed as expected. False if /// something went wrong (in that case, the user will be informed /// and details will be written to the log file).</returns> public virtual bool Execute(ExecutionContext context) { try { // Assume that each derived class will implement // ToString with a description of what's in the // command line. Log.Trace(ToString()); ICmdHandler handler = GetCommandHandler(context); if (handler == null) { throw new ApplicationException("Cannot obtain a command handler"); } handler.Process(context); return(true); } catch (Exception ex) { ShowError(ex); } return(false); }
/// <summary> /// 移除命令监听对象 /// </summary> /// <param name="handler"></param> public void RemoveCmdHandler(ICmdHandler handler) { if (CmdHandlers.Contains(handler)) { CmdHandlers.Remove(handler); } }
/// <summary> /// 添加命令监听对象 /// </summary> /// <param name="handler"></param> public void AddCmdHandler(ICmdHandler handler) { if (CmdHandlers.Contains(handler)) { return; } CmdHandlers.Add(handler); }
public bool ExistCmdHandler(ICmdHandler handler) { try { return(handles.Exists(handle => handle.name.Equals(handler?.name))); } catch { return(false); } }
public bool UnRegisterCmdHandle(ICmdHandler handler) { if (!ExistCmdHandler(handler)) { return(false); } handles.Remove(handler); return(true); }
public bool RegisterCmdHandle(ICmdHandler handler) { if (ExistCmdHandler(handler)) { return(false); } handles.Add(handler); return(true); }
public PostController(IQryExecutor qryExecutor, ICmdHandler cmdHandler) : base(qryExecutor, cmdHandler) { }
public CmdDecorator(ICmdHandler <T> decorated, ITestLogger logger) { _decorated = decorated; _logger = logger; }
public DashboardController(IQryExecutor qryExecutor, ICmdHandler cmdHandler) : base(qryExecutor, cmdHandler) { }
public BaseApiController(IQryExecutor qryExecutor, ICmdHandler cmdHandler) { _qryExecutor = qryExecutor; _cmdHandler = cmdHandler; }
public void GlobalInit() { m_Handler = null; }
public void ClearCmdAndHandler() { m_Handler = null; m_CmdList.Clear(); }
public CategoryController(IQryExecutor qryExecutor, ICmdHandler cmdHandler) : base(qryExecutor, cmdHandler) { }