Undo system

The NanoByte.Common.Undo namespace provides a framework for adding undo/redo functionality to your applications.

Commands

Commands that can be executed and also undone are represented using the IUndoCommand interface.

This library provides a number of implementations for common use cases such as SetValueCommand and AddToCollection, but you can also implement your own.

Executors

Methods that want to execute IUndoCommands should take an ICommandExecutor as an input parameter.
To execute an IUndoCommand, pass it to the ICommandExecutor.Execute() method. This will then internally call IUndoCommand.Execute() and record the command for later undo operations.

The class CommandManager<T> implements the ICommandExecutor interface. You can expose the .Undo() and .Redo() methods of this class to your users in your GUI.