Table of Contents

Class CommandInvoker

The Invoker in the Command pattern. Executes ICommand instances and maintains a history stack that allows undoing operations in LIFO order.

public class CommandInvoker
Inheritance
CommandInvoker
Inherited Members

Remarks

Typical usage: wire UI buttons (Do / Undo) to ExecuteCommand(ICommand) and UndoLastCommand() respectively.

Methods

ExecuteCommand(ICommand)

Executes the given command and pushes it onto the undo history stack.

public void ExecuteCommand(ICommand command)

Parameters

command ICommand

The command to execute.

UndoLastCommand()

Pops and undoes the most recently executed command. Does nothing if the history is empty.

public void UndoLastCommand()