Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 移除命令监听对象
 /// </summary>
 /// <param name="handler"></param>
 public void RemoveCmdHandler(ICmdHandler handler)
 {
     if (CmdHandlers.Contains(handler))
     {
         CmdHandlers.Remove(handler);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 添加命令监听对象
 /// </summary>
 /// <param name="handler"></param>
 public void AddCmdHandler(ICmdHandler handler)
 {
     if (CmdHandlers.Contains(handler))
     {
         return;
     }
     CmdHandlers.Add(handler);
 }
Exemplo n.º 4
0
 public bool ExistCmdHandler(ICmdHandler handler)
 {
     try
     {
         return(handles.Exists(handle => handle.name.Equals(handler?.name)));
     }
     catch { return(false); }
 }
Exemplo n.º 5
0
 public bool UnRegisterCmdHandle(ICmdHandler handler)
 {
     if (!ExistCmdHandler(handler))
     {
         return(false);
     }
     handles.Remove(handler);
     return(true);
 }
Exemplo n.º 6
0
 public bool RegisterCmdHandle(ICmdHandler handler)
 {
     if (ExistCmdHandler(handler))
     {
         return(false);
     }
     handles.Add(handler);
     return(true);
 }
Exemplo n.º 7
0
 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)
 {
 }
Exemplo n.º 10
0
 public BaseApiController(IQryExecutor qryExecutor, ICmdHandler cmdHandler)
 {
     _qryExecutor = qryExecutor;
     _cmdHandler  = cmdHandler;
 }
Exemplo n.º 11
0
 public void GlobalInit()
 {
     m_Handler = null;
 }
Exemplo n.º 12
0
 public void ClearCmdAndHandler()
 {
     m_Handler = null;
     m_CmdList.Clear();
 }
Exemplo n.º 13
0
 public CategoryController(IQryExecutor qryExecutor, ICmdHandler cmdHandler)
     : base(qryExecutor, cmdHandler)
 {
 }