Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command{T}" /> class.
        /// </summary>
        /// <param name="execute">The execution method.</param>
        /// <param name="canExecute">The function to test whether the <paramref name="execute" /> method may be invoked.</param>
        /// <param name="options">The options.</param>
        /// <exception cref="ArgumentNullException"><paramref name="execute" /> is <c>null</c>.</exception>
        public Command([NotNull] Action <T, CancellationToken> execute, Func <T, bool> canExecute = null, CommandOptions options = null)
            : base(false, canExecute, options ?? CommandOptions.Default)
        {
            if (execute == null)
            {
                throw new ArgumentNullException(nameof(execute));
            }

            this.execute = (arg, _, cancellationToken) => execute(arg, cancellationToken);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Command{T}" /> class.
 /// </summary>
 /// <param name="execute">The execution method.</param>
 /// <param name="canExecute">The function to test whether the <paramref name="execute" /> method may be invoked.</param>
 /// <param name="options">The options.</param>
 /// <exception cref="ArgumentNullException"><paramref name="execute" /> is <c>null</c>.</exception>
 public Command(
     [NotNull] Action <T, CommandExecutionController, CancellationToken> execute,
     Func <T, bool> canExecute = null,
     CommandOptions options    = null) : base(false, canExecute, options ?? CommandOptions.Default)
     => this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
Пример #3
0
 internal ParameterizedCommand(bool isThreadSafe, Func <T, bool> canExecute, [NotNull] CommandOptions options) : base(isThreadSafe, options)
     => this.canExecute = canExecute;
Пример #4
0
 internal CommandBase(bool isThreadSafe, [NotNull] CommandOptions options) : base(isThreadSafe) => Options = options;
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncCommand" /> class.
 /// </summary>
 /// <param name="execute">The execution method.</param>
 /// <param name="canExecute">The function to test whether the <paramref name="execute" /> method may be invoked.</param>
 /// <param name="options">The options.</param>
 /// <exception cref="ArgumentNullException"><paramref name="execute" /> is <c>null</c>.</exception>
 public AsyncCommand(
     [NotNull] Func <CommandExecutionController, CancellationToken, Task> execute,
     Func <bool> canExecute = null,
     CommandOptions options = null) : base(true, canExecute, options ?? CommandOptions.DefaultAsync)
     => this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncCommand" /> class.
        /// </summary>
        /// <param name="execute">The execution method.</param>
        /// <param name="canExecute">The function to test whether the <paramref name="execute" /> method may be invoked.</param>
        /// <param name="options">The options.</param>
        /// <exception cref="ArgumentNullException"><paramref name="execute" /> is <c>null</c>.</exception>
        public AsyncCommand([NotNull] Func <CancellationToken, Task> execute, Func <bool> canExecute = null, CommandOptions options = null)
            : base(true, canExecute, options ?? CommandOptions.DefaultAsync)
        {
            if (execute == null)
            {
                throw new ArgumentNullException(nameof(execute));
            }

            this.execute = (_, cancellationToken) => execute(cancellationToken);
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncCommand{T}" /> class.
        /// </summary>
        /// <param name="execute">The execution method.</param>
        /// <param name="canExecute">The function to test whether the <paramref name="execute" /> method may be invoked.</param>
        /// <param name="options">The options.</param>
        /// <exception cref="ArgumentNullException"><paramref name="execute" /> is <c>null</c>.</exception>
        public AsyncCommand([NotNull] Func <T, Task> execute, Func <T, bool> canExecute = null, CommandOptions options = null)
            : base(true, canExecute, options ?? CommandOptions.DefaultAsync)
        {
            if (execute == null)
            {
                throw new ArgumentNullException(nameof(execute));
            }

            this.execute = (arg, _, __) => execute(arg);
        }