public void Test() { Document doc = new Document(); Command display = new Display(doc); Command undo = new Undo(doc); Command redo = new Redo(doc); DocumentInvoker invoker = new DocumentInvoker(display, undo, redo); invoker.Display(); invoker.Undo(); invoker.Redo(); Console.ReadLine(); }
public Print(Document doc) { Execute = delegate { Execute.Log(); doc.Print(); }; Undo = delegate { Undo.Log(); Console.WriteLine("This action cannot be Undone"); }; Redo = delegate { Redo.Log(); doc.Print(); }; }
public Paste(Document doc) { Execute = delegate { Execute.Log(); doc.Paste(); }; Undo = delegate { Undo.Log(); doc.Restore(); }; Redo = delegate { Redo.Log(); doc.Paste(); }; }