CommandPattern 1.0.0
This package contains a collection of classes and interfaces to allow for quick and consistent implementation of the command pattern across projects.
|
The base class of all commands who's execute method involves asynchronous tasks More...
Public Member Functions | |
sealed override void | Execute () |
This method may not be overridden in asynchronous commands. Use ExecuteAsync for your command's logic instead. More... | |
abstract Task | ExecuteAsync () |
Executes the command asynchronously. Remember to add the async keyword as that is not considered part of the method signature and cannot be added to abstract methods. IMPORTANT: if you want to be able to cancel the AsyncCommand's task you must invoke CancellationToken.ThrowIfCancellationRequested() within this method somewhere after the first await. If you do not do so attempting to cancel it will do nothing. More... | |
abstract void | Execute () |
Executes the command, do not invoke directly, instead use a CommandStream. More... | |
abstract void | Execute () |
Executes the function of the command More... | |
abstract Task | ExecuteAsync () |
This is where the logic of executing the command should be placed for an AsyncCommand, Execute should just store the return in CommandTask and setup the OnTaskCompleted method. Remember to make this method async as that isn't considered part of its signature. More... | |
Properties | |
Task | CommandTask [get] |
The task for the completion of the ExecuteAsync method after it reaches its first await and returns control back to the calling method (CommandStream.TryExecuteNext()) More... | |
CancellationToken | CancellationToken [get, set] |
This can be used in ExecuteAsync to determine if the CommandTask has been canceled. More... | |
![]() | |
Task | CommandTask [get] |
This should get the asynchronous task returned by ExecuteAsync after it reaches its first await More... | |
CancellationToken | CancellationToken [get, set] |
This can be used to Cancel the task after it has been started. More... | |
Events | |
Action | OnTaskCompleted |
This event is invoked when CommandTask is completed. I.E. - when we reach the end of ExecuteAsync(). Subscribe to it to preform an action at after the command has fully completed. | |
Action | OnTaskCanceled |
This event is invoked if the command task is canceled. Most bookkeeping that occurs in this situation is handled by the package but you can subscribe to this as well if needed. | |
Action< Exception > | OnTaskFaulted |
This event is invoked if the command task throws an exception. | |
Action | OnAnyTaskEnd |
This event is invoked when any of the OnTask[blank] events are to avoid needed to subscribe the same delegate to multiple events when logic needs to run regardless of how the task finished | |
![]() | |
Action | OnTaskCompleted |
This event should be invoked when CommandTask is successfully completed. | |
Action | OnTaskCanceled |
This event should be invoked when CommandTask is cancelled. | |
Action< Exception > | OnTaskFaulted |
This event should be invoked when CommandTask throws an exception | |
Action | OnAnyTaskEnd |
This event should be invoked when any of the above three are | |
The base class of all commands who's execute method involves asynchronous tasks
|
virtual |
This method may not be overridden in asynchronous commands. Use ExecuteAsync for your command's logic instead.
Implements SadSapphicGames.CommandPattern.Command.
|
pure virtual |
Executes the command asynchronously. Remember to add the async keyword as that is not considered part of the method signature and cannot be added to abstract methods.
IMPORTANT: if you want to be able to cancel the AsyncCommand's task you must invoke CancellationToken.ThrowIfCancellationRequested() within this method somewhere after the first await. If you do not do so attempting to cancel it will do nothing.
Implements SadSapphicGames.CommandPattern.IAsyncCommand.
|
getset |
This can be used in ExecuteAsync to determine if the CommandTask has been canceled.
Implements SadSapphicGames.CommandPattern.IAsyncCommand.
|
get |
The task for the completion of the ExecuteAsync method after it reaches its first await and returns control back to the calling method (CommandStream.TryExecuteNext())
Implements SadSapphicGames.CommandPattern.IAsyncCommand.