static void Main() { Originator o = new Originator(); o.State = "On"; Caretaker c = new Caretaker(); c.Memento = o.CreateMemento(); o.State = "Off"; o.SetMemento(c.Memento); Console.ReadKey(); }
/// <summary> /// Entry point into console application. /// </summary> static void Main() { Originator o = new Originator(); o.State = "On"; // Store internal state Caretaker c = new Caretaker(); c.Memento = o.CreateMemento(); // Continue changing originator o.State = "Off"; // Restore saved state o.SetMemento(c.Memento); // Wait for user Console.ReadKey(); }