Esempio n. 1
0
        void Target_ExecuteCommand(object sender, EventArgs e)
        {
            if (Enabled)
            {
                var isAsyncCommand = Source is IAsyncCommand;

                BeforeExecuteAction?.Invoke(this);
                if (!isAsyncCommand && CommandStarted != null)
                {
                    CommandStarted(this);
                }
                var parameter = GetParameter(sender, e);
                try
                {
                    Source.Execute(Parameter);
                }
                finally
                {
                    AfterExecuteAction?.Invoke(this);
                    if (!isAsyncCommand && CommandFinished != null)
                    {
                        CommandFinished(this);
                    }
                }
            }
        }
Esempio n. 2
0
        void Target_ExecuteCommand(object parameter)
        {
            if (Enabled)
            {
                parameter = Parameter ?? parameter;
                var isAsyncCommand = Command is IAsyncCommand;

                BeforeExecuteAction?.Invoke(this);
                if (!isAsyncCommand)
                {
                    CommandStarted?.Invoke(this);
                }
                try
                {
                    Command.Execute(parameter);
                }
                finally
                {
                    AfterExecuteAction?.Invoke(this);
                    if (!isAsyncCommand)
                    {
                        CommandFinished?.Invoke(this);
                    }
                }
            }
        }