Concrete Command (AddTextCommand):?
- The AddTextCommand is a concrete implementation of the ICommand
interface. It encapsulates the request to add text to the document.
- The Execute() method adds the specified text to the document, and the
Undo() method removes that text.
public class AddTextCommand : ICommand
private readonly Document _document;
private readonly string _text;
public AddTextCommand(Document document, string text)
_document = document;
_text = text;
public void Execute() => _document.AddText(_text);
public void Undo() => _document.RemoveText(_text);