예제 #1
0
        public async Task ExecuteAsync(object parameter = null)
        {
            PreExecution?.Invoke(this, new ExecuteTaskEventArgs {
                IsExecuting = true
            });
            await _execute(parameter);

            RaiseCanExecuteChanged();
        }
예제 #2
0
        public void Execute(
            object parameter)
        {
            PreExecution?.Invoke(
                this,
                new RelayCommandEventArgs(parameter));

            var p = parameter is T
                ? (T)parameter
                : (T)Convert.ChangeType(
                parameter,
                typeof(T));

            _execute(
                p);

            PostExecution?.Invoke(
                this,
                new RelayCommandEventArgs(parameter));
        }
 /// <summary>
 /// Defines the method to be called when the command is invoked.
 /// </summary>
 /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
 /// <exception cref="Exception"><see cref="PreExecution"/>'s, <see cref="PostExecution"/>'s or <see cref="execute"/>'s callback throws an exception.</exception>
 public void Execute(object parameter)
 {
     PreExecution?.Invoke(this, new DataEventArgs <object>(parameter));
     execute(ConversionHelper.ConvertValue <T>(parameter));
     PostExecution?.Invoke(this, new DataEventArgs <object>(parameter));
 }
예제 #4
0
 /// <summary>
 /// Defines the method to be called when the command is invoked.
 /// </summary>
 /// <param name="parameter">data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
 /// <exception cref="Exception"><see cref="PreExecution"/>'s, <see cref="PostExecution"/>'s or <see cref="execute"/>'s callback throws an exception.</exception>
 public void Execute(object parameter)
 {
     PreExecution?.Invoke(this, new DataEventArgs <object>(parameter));
     execute(parameter);
     PostExecution?.Invoke(this, new DataEventArgs <object>(parameter));
 }