Table of Contents

Class CommandInvoker

Namespace
Core.CliniCore.Commands
Assembly
Core.CliniCore.dll

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

bool

CanUndo

Gets a value indicating whether there are commands that can be undone.

public bool CanUndo { get; }

Property Value

bool

History

Gets the command execution history.

public IReadOnlyList<CommandExecutionRecord> History { get; }

Property Value

IReadOnlyList<CommandExecutionRecord>

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

command ICommand

The command to execute.

parameters CommandParameters

The parameters for the command.

session SessionContext

The current session context, or null if 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

command ICommand

The command to execute.

parameters CommandParameters

The parameters for the command.

session SessionContext

The current session context, or null if 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

commands IEnumerable<(ICommand Command, CommandParameters Parameters)>

The commands and their parameters to execute.

session SessionContext

The current session context.

stopOnFirstFailure bool

If 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

parameters CommandParameters

The parameters to use when re-executing the command.

session SessionContext

The 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

session SessionContext

The current session context.

Returns

CommandResult

The result of the undo operation.