/// <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();
        }
Example #2
0
        /// <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();
        }