Gorgon
Show / Hide Table of Contents

Class EditorAsyncCommand<T>

An implementation of the IEditorAsyncCommand<T> interface.

Inheritance
object
EditorAsyncCommand<T>
Implements
IEditorAsyncCommand<T>
IEditorCommand<T>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

EditorAsyncCommand(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 execute parameter is null.

See Also
IEditorCommand<T>
| Edit this page View Source

EditorAsyncCommand(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 execute parameter is null.

See Also
IEditorCommand<T>

Methods

| Edit this page View Source

CanExecute(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
IEditorCommand<T>
| Edit this page View Source

Execute(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
IEditorCommand<T>
| Edit this page View Source

ExecuteAsync(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.

See Also
IEditorCommand<T>

Implements

IEditorAsyncCommand<T>
IEditorCommand<T>

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

IEditorCommand<T>
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author