public ICommand ToCommand() { ICanExecuteStrategy <T> canExecuteStrategy; if (CanExecutePredicate == null && ObservablePredicate == null) { canExecuteStrategy = new AlwaysTrueCanExecuteStrategy <T>(); } else if (CanExecutePredicate != null) { canExecuteStrategy = new SingleExecutionCanExecuteStrategy <T>(CanExecutePredicate); } else { canExecuteStrategy = new ObserveCanExecuteStrategy <T>(ObservablePredicate, new AlwaysTrueCanExecuteStrategy <T>()); } ICommand command = new Command <T>(Action, _schedulers, _name, canExecuteStrategy); _saveAction(command); return(command); }
public ICommand ToCommand() { ICommand command; ICanExecuteStrategy <TCommand> canExecuteStrategy; if (CanExecutePredicate == null && ObservableCanExecute == null) { canExecuteStrategy = new SingleExecutionCanExecuteStrategy <TCommand>(_ => true); } else if (CanExecutePredicate != null) { if (IsMultipleExecution) { canExecuteStrategy = new MultipleExecutionCanExecuteStrategy <TCommand>(CanExecutePredicate); } else { canExecuteStrategy = new SingleExecutionCanExecuteStrategy <TCommand>(CanExecutePredicate); } } else { canExecuteStrategy = IsMultipleExecution ? new ObserveCanExecuteStrategy <TCommand>(ObservableCanExecute, new MultipleExecutionCanExecuteStrategy <TCommand>(_ => true)) : new ObserveCanExecuteStrategy <TCommand>(ObservableCanExecute, new SingleExecutionCanExecuteStrategy <TCommand>(_ => true)); } command = new ObservableMvvmCommand <TCommand, TObservable>( Observable, _schedulers, ExecutionScheduler ?? _schedulers.ThreadPool, _name, canExecuteStrategy, DoObserver, DoScheduler, ErrorTask); _saveAction(command); return(command); }