Ejemplo n.º 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);
        }
Ejemplo n.º 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));
Ejemplo n.º 3
0
 internal ParameterizedCommand(bool isThreadSafe, Func <T, bool> canExecute, [NotNull] CommandOptions options) : base(isThreadSafe, options)
     => this.canExecute = canExecute;
Ejemplo n.º 4
0
 internal CommandBase(bool isThreadSafe, [NotNull] CommandOptions options) : base(isThreadSafe) => Options = options;
Ejemplo n.º 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));
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }