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 |
---|---|---|
System.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, Boolean>)
Initializes a new instance of DelegateCommand<T>.
Declaration
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | executeMethod | Delegate to execute when Execute is called on the command. This can be null to just hook up a CanExecute delegate. |
System.Func<T, System.Boolean> | canExecuteMethod | Delegate to execute when CanExecute is called on the command. This can be null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When both |
Methods
View SourceCanExecute(T)
Determines if the command can execute by invoked the System.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 |
---|---|
System.Boolean | true if this command can be executed; otherwise, false. |
Execute(T)
Executes the command and invokes the System.Action<T> provided during construction.
Declaration
public void Execute(T parameter)
Parameters
Type | Name | Description |
---|---|---|
T | parameter | Data used by the command. |