Class EditorAsyncCommand<T>
An implementation of the IEditorAsyncCommand<T> interface.
Inherited Members
Namespace: Gorgon.Editor.UI
Assembly: Gorgon.Editor.API.dll
Syntax
public class EditorAsyncCommand<T> : IEditorAsyncCommand<T>, IEditorCommand<T>
Type Parameters
Name | Description |
---|---|
T | The type of data to pass to the command. |
Remarks
Commands are used to perform actions on a view model. They work similarly to events in that they are usually called in response to a UI action like a button click.
Unlike the IEditorCommand<T> type, this allows commands to execute asynchronously and await the results on the view so that order of execution can be guaranteed even on the view.
Constructors
| Edit this page View SourceEditorAsyncCommand(Func<Task>, Func<bool>)
Initializes a new instance of the EditorCommand<T> class.
Declaration
public EditorAsyncCommand(Func<Task> execute, Func<bool> canExecute = null)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | execute | The method to execute when the command is executed. |
Func<bool> | canExecute | The method used to determine if the command can execute. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceEditorAsyncCommand(Func<T, Task>, Func<T, bool>)
Initializes a new instance of the EditorCommand<T> class.
Declaration
public EditorAsyncCommand(Func<T, Task> execute, Func<T, bool> canExecute = null)
Parameters
Type | Name | Description |
---|---|---|
Func<T, Task> | execute | The method to execute when the command is executed. |
Func<T, bool> | canExecute | The method used to determine if the command can execute. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
Methods
| Edit this page View SourceCanExecute(T)
Function to determine if a command can be executed or not.
Declaration
public bool CanExecute(T args)
Parameters
Type | Name | Description |
---|---|---|
T | args | The arguments to check. |
Returns
Type | Description |
---|---|
bool | true if the command can be executed, false if not. |
See Also
| Edit this page View SourceExecute(T)
Function to execute the command.
Declaration
public void Execute(T args)
Parameters
Type | Name | Description |
---|---|---|
T | args | The arguments to pass to the command. |
See Also
| Edit this page View SourceExecuteAsync(T)
Function to execute the command.
Declaration
public Task ExecuteAsync(T args)
Parameters
Type | Name | Description |
---|---|---|
T | args | The arguments to pass to the command. |
Returns
Type | Description |
---|---|
Task | A Task for asynchronous operation. |