C# Class Microsoft.Sarif.Viewer.DelegateCommand

An ICommand whose delegates can be attached for Execute and CanExecute.
The constructor deliberately prevents the use of value types. Because ICommand takes an object, having a value type for T would cause unexpected behavior when CanExecute(null) is called during XAML initialization for command bindings. Using default(T) was considered and rejected as a solution because the implementor would not be able to distinguish between a valid and defaulted values. Instead, callers should support a value type by using a nullable value type and checking the HasValue property before using the Value property. public MyClass() { this.submitCommand = new DelegateCommand<int?>(this.Submit, this.CanSubmit); } private bool CanSubmit(int? customerId) { return (customerId.HasValue && customers.Contains(customerId.Value)); }
Inheritance: DelegateCommandBase
Afficher le fichier Open project: microsoft/sarif-visualstudio-extension

Méthodes publiques

Méthode Description
CanExecute ( parameter ) : bool

Determines if the command can execute by invoked the Func{T,Bool} provided during construction.

DelegateCommand ( Action executeMethod ) : System

Initializes a new instance of the DelegateCommand{T} class.

CanExecute will always return true.

DelegateCommand ( Action executeMethod, Func canExecuteMethod ) : System

Initializes a new instance of the DelegateCommand{T} class.

ExecuteAsync ( parameter ) : Task

Executes the command and invokes the Action{T} provided during construction.

FromAsyncHandler ( Func executeMethod ) : DelegateCommand

Factory method to create a new instance of DelegateCommand{T} from an awaitable handler method.

FromAsyncHandler ( Func executeMethod, Func canExecuteMethod ) : DelegateCommand

Factory method to create a new instance of DelegateCommand{T} from an awaitable handler method.

Private Methods

Méthode Description
DelegateCommand ( Func executeMethod ) : System
DelegateCommand ( Func executeMethod, Func canExecuteMethod ) : System

Method Details

CanExecute() public méthode

Determines if the command can execute by invoked the Func{T,Bool} provided during construction.
public CanExecute ( parameter ) : bool
parameter Data used by the command to determine if it can execute.
Résultat bool

DelegateCommand() public méthode

Initializes a new instance of the DelegateCommand{T} class.
CanExecute will always return true.
public DelegateCommand ( Action executeMethod ) : System
executeMethod Action Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate.
Résultat System

DelegateCommand() public méthode

Initializes a new instance of the DelegateCommand{T} class.
When both and ar .
public DelegateCommand ( Action executeMethod, Func canExecuteMethod ) : System
executeMethod Action Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate.
canExecuteMethod Func Delegate to execute when CanExecute is called on the command. This can be null.
Résultat System

ExecuteAsync() public méthode

Executes the command and invokes the Action{T} provided during construction.
public ExecuteAsync ( parameter ) : Task
parameter Data used by the command.
Résultat Task

FromAsyncHandler() public static méthode

Factory method to create a new instance of DelegateCommand{T} from an awaitable handler method.
public static FromAsyncHandler ( Func executeMethod ) : DelegateCommand
executeMethod Func Delegate to execute when Execute is called on the command.
Résultat DelegateCommand

FromAsyncHandler() public static méthode

Factory method to create a new instance of DelegateCommand{T} from an awaitable handler method.
public static FromAsyncHandler ( Func executeMethod, Func canExecuteMethod ) : DelegateCommand
executeMethod Func Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate.
canExecuteMethod Func Delegate to execute when CanExecute is called on the command. This can be null.
Résultat DelegateCommand