static void Main(string[] args)
        {
            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();
        }
Example #2
0
 public Originator(Caretaker caretaker)
 {
     this.caretaker = caretaker;
 }