예제 #1
0
        /// <summary>
        /// 执行这个命令
        /// </summary>
        /// <param name="param"></param>
        internal void Execute()
        {
            //调试阶段如果接住了异常,会比较难以调试,所以调试期关闭异常事件。。
            if (!RafyEnvironment.IsDebuggingEnabled)
            {
                try
                {
                    this.OnExecuting();

                    this.ExecuteCore();

                    this.OnExecuted(new CommandExecutedArgs(this.Parameter));
                }
                catch (Exception ex)
                {
                    var args = new CommandExecuteFailedArgs(ex, this.Parameter);

                    this.OnExecuteFailed(args);

                    if (!args.Cancel)
                    {
                        throw ex;
                    }
                }
            }
            else
            {
                this.OnExecuting();

                this.ExecuteCore();

                this.OnExecuted(new CommandExecutedArgs(this.Parameter));
            }
        }
예제 #2
0
        protected virtual void OnExecuteFailed(CommandExecuteFailedArgs e)
        {
            var handler = this.ExecuteFailed;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #3
0
 protected virtual void OnExecuteFailed(CommandExecuteFailedArgs e)
 {
     var handler = this.ExecuteFailed;
     if (handler != null) handler(this, e);
 }
예제 #4
0
        /// <summary>
        /// 执行这个命令
        /// </summary>
        /// <param name="param"></param>
        internal void Execute()
        {
            //调试阶段如果接住了异常,会比较难以调试,所以调试期关闭异常事件。。
            if (!RafyEnvironment.IsDebuggingEnabled)
            {
                try
                {
                    this.OnExecuting();

                    this.ExecuteCore();

                    this.OnExecuted(new CommandExecutedArgs(this.Parameter));
                }
                catch (Exception ex)
                {
                    var args = new CommandExecuteFailedArgs(ex, this.Parameter);

                    this.OnExecuteFailed(args);

                    if (!args.Cancel) throw ex;
                }
            }
            else
            {
                this.OnExecuting();

                this.ExecuteCore();

                this.OnExecuted(new CommandExecutedArgs(this.Parameter));
            }
        }