Class DelegateCommand<T>
Namespace: Sartorius.SAF.Presentation.Commands
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class DelegateCommand<T> : DelegateCommandBase, ICommand, IActiveAware
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
View SourceDelegateCommand(Action<T>)
Initializes a new instance of DelegateCommand<T>.
Declaration
public DelegateCommand(Action<T> executeMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | executeMethod | Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate. |
Remarks
CanExecute(T) will always return true.
DelegateCommand(Action<T>, Func<T, bool>)
Initializes a new instance of DelegateCommand<T>.
Declaration
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | executeMethod | Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate. |
| Func<T, bool> | canExecuteMethod | Delegate to execute when CanExecute is called on the command. This can be null. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | When both |
Methods
View SourceCanExecute(T)
Determines if the command can execute by invoked the Func<T, TResult> provided during construction.
Declaration
public bool CanExecute(T parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| T | parameter | Data used by the command to determine if it can execute. |
Returns
| Type | Description |
|---|---|
| bool |
Execute(T)
Executes the command and invokes the Action<T> provided during construction.
Declaration
public void Execute(T parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| T | parameter | Data used by the command. |