Class CommandInvoker
Orchestrates command execution, manages command history, and handles undo/redo operations.
public class CommandInvoker
- Inheritance
-
CommandInvoker
- Inherited Members
Constructors
CommandInvoker()
Initializes a new instance of the CommandInvoker class.
public CommandInvoker()
Properties
CanRedo
Gets a value indicating whether there are commands that can be redone.
public bool CanRedo { get; }
Property Value
CanUndo
Gets a value indicating whether there are commands that can be undone.
public bool CanUndo { get; }
Property Value
History
Gets the command execution history.
public IReadOnlyList<CommandExecutionRecord> History { get; }
Property Value
Methods
ClearHistory()
Clears the command history, including undo and redo stacks.
public void ClearHistory()
Execute(ICommand, CommandParameters, SessionContext?)
Executes a command with the given parameters.
public CommandResult Execute(ICommand command, CommandParameters parameters, SessionContext? session)
Parameters
commandICommandThe command to execute.
parametersCommandParametersThe parameters for the command.
sessionSessionContextThe current session context, or
nullif not authenticated.
Returns
- CommandResult
The result of the command execution.
ExecuteAsync(ICommand, CommandParameters, SessionContext?)
Executes a command asynchronously.
public Task<CommandResult> ExecuteAsync(ICommand command, CommandParameters parameters, SessionContext? session)
Parameters
commandICommandThe command to execute.
parametersCommandParametersThe parameters for the command.
sessionSessionContextThe current session context, or
nullif not authenticated.
Returns
- Task<CommandResult>
A task that represents the asynchronous operation and contains the command result.
ExecuteBatch(IEnumerable<(ICommand Command, CommandParameters Parameters)>, SessionContext?, bool)
Executes multiple commands as a batch (transaction-like).
public BatchCommandResult ExecuteBatch(IEnumerable<(ICommand Command, CommandParameters Parameters)> commands, SessionContext? session, bool stopOnFirstFailure = true)
Parameters
commandsIEnumerable<(ICommand Command, CommandParameters Parameters)>The commands and their parameters to execute.
sessionSessionContextThe current session context.
stopOnFirstFailureboolIf set to
true, stops executing further commands when the first failure occurs.
Returns
- BatchCommandResult
A BatchCommandResult describing the outcome of the batch execution.
GetRedoableCommands()
Gets the names of commands available for redo.
public IEnumerable<string> GetRedoableCommands()
Returns
- IEnumerable<string>
A collection of command names that can be redone.
GetUndoableCommands()
Gets the names of commands available for undo.
public IEnumerable<string> GetUndoableCommands()
Returns
- IEnumerable<string>
A collection of command names that can be undone.
Redo(CommandParameters, SessionContext?)
Redoes the last undone command.
public CommandResult Redo(CommandParameters parameters, SessionContext? session)
Parameters
parametersCommandParametersThe parameters to use when re-executing the command.
sessionSessionContextThe current session context.
Returns
- CommandResult
The result of the redo operation.
Undo(SessionContext?)
Undoes the last executed command that supports undo.
public CommandResult Undo(SessionContext? session)
Parameters
sessionSessionContextThe current session context.
Returns
- CommandResult
The result of the undo operation.