Beispiel #1
0
        /// <summary>
        /// The invoke executing.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private void InvokeExecuting(CancelCommandEventArgs args)
        {
            CancelCommandEventHandler executing = Executing;

            if (executing != null)
            {
                executing(this, args);
            }
        }
Beispiel #2
0
        protected void InvokeExecuting(CancelCommandEventArgs args)
        {
            CancelCommandEventHandler executing = Executing;

            //  Call the executed event.
            if (executing != null)
            {
                executing(this, args);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="param">The param.</param>
        public virtual void DoExecute(object param)
        {
            //  Get copies of the two event handlers we'll be using.
            //  We get them here to protect against the event timing anti-pattern.
            CancelCommandEventHandler executing = Executing;
            CommandEventHandler       executed  = Executed;

            //  Do we have an 'executing' event?
            if (executing != null)
            {
                //  Call the event.
                CancelCommandEventArgs args =
                    new CancelCommandEventArgs()
                {
                    Parameter = param
                };
                executing(this, args);
                //  If the event has been cancelled, bail now.
                if (args.Cancel)
                {
                    return;
                }
            }
            //  Call the action or the parameterized action, whichever has been set.
            if (action != null)
            {
                action();
            }
            else if (parameterizedAction != null)
            {
                parameterizedAction(param);
            }
            //  Call the executed event.
            if (executed != null)
            {
                executed(this, new CommandEventArgs()
                {
                    Parameter = param
                });
            }
        }