/// <summary> /// Initializes a new instance of the <see cref="ConcurrencyAsyncCommandBase" /> class. /// </summary> /// <param name="execute">The execute.</param> /// <param name="completed">The completed.</param> /// <param name="error">The error.</param> /// <param name="cancel">The cancel.</param> protected ConcurrencyAsyncCommandBase( [NotNull] Func <CancellationToken, Task> execute, [CanBeNull] Func <Task> completed = null, [CanBeNull] Func <Exception, Task> error = null, [CanBeNull] Func <Task> cancel = null) { this.execute = execute; this.completed = completed; this.error = error; this.cancel = cancel; this.cancelCommand = new DirectCommand(this.Cancel, () => this.IsExecuting); }
/// <summary> /// Initializes a new instance of the <see cref="ConcurrencyCommandBase" /> class. /// </summary> /// <param name="execute">The execute.</param> /// <param name="completed">The completed.</param> /// <param name="error">The error.</param> /// <param name="cancel">The cancel.</param> protected ConcurrencyCommandBase( [NotNull] Action <CancellationToken> execute, [CanBeNull] Action completed = null, [CanBeNull] Action <Exception> error = null, [CanBeNull] Action cancel = null) { this.execute = execute; this.completed = completed; this.error = error; this.cancel = cancel; this.cancelCommand = new DirectCommand(this.Cancel, () => this.IsExecuting); }
/// <summary> /// Initializes a new instance of the <see cref="ConcurrencyCommandBase" /> class. /// </summary> /// <param name="execute">The execute.</param> /// <param name="canExecuteSubject">The can execute subject.</param> /// <param name="completed">The completed.</param> /// <param name="error">The error.</param> /// <param name="cancel">The cancel.</param> /// <exception cref="ArgumentNullException">canExecuteSubject is null.</exception> protected ConcurrencyCommandBase( [NotNull] Action <CancellationToken> execute, [NotNull] ICanExecuteSubject canExecuteSubject, [CanBeNull] Action completed = null, [CanBeNull] Action <Exception> error = null, [CanBeNull] Action cancel = null) { this.execute = execute; if (canExecuteSubject == null) { throw new ArgumentNullException(nameof(canExecuteSubject)); } this.canExecute = canExecuteSubject.CanExecute; this.completed = completed; this.error = error; this.cancel = cancel; this.cancelCommand = new DirectCommand(this.Cancel, () => this.IsExecuting); }
/// <summary> /// Initializes a new instance of the <see cref="ConcurrencyAsyncCommandBase{T}" /> class. /// </summary> /// <param name="execute">The execute.</param> /// <param name="canExecuteSubject">The can execute subject.</param> /// <param name="completed">The completed.</param> /// <param name="error">The error.</param> /// <param name="cancel">The cancel.</param> /// <exception cref="ArgumentNullException">canExecuteSubject is null.</exception> protected ConcurrencyAsyncCommandBase( [NotNull] Func <T, CancellationToken, Task> execute, [NotNull] ICanExecuteSubject canExecuteSubject, [CanBeNull] Func <Task> completed = null, [CanBeNull] Func <Exception, Task> error = null, [CanBeNull] Func <Task> cancel = null) { this.execute = execute; if (canExecuteSubject == null) { throw new ArgumentNullException(nameof(canExecuteSubject)); } this.canExecute = _ => canExecuteSubject.CanExecute(); this.completed = completed; this.error = error; this.cancel = cancel; this.cancelCommand = new DirectCommand(this.Cancel, () => this.IsExecuting); }