Beispiel #1
0
        static void Food()
        {
            var supplier = new FoodSupplier
            {
                Name  = "Jordan Woodruff",
                Phone = "8068675309",
            };

            SupplierMemory memory = new SupplierMemory(supplier.SaveMemento());

            supplier.Address = "132 Sesame St.";

            supplier.RestoreMemento(memory.FoodSupplierMemento);

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Here's a new supplier for our restaurant
            FoodSupplier s = new FoodSupplier();

            s.Name  = "Harold Karstark";
            s.Phone = "(482) 555-1172";

            // Let's store that entry in our database.
            SupplierMemory m = new SupplierMemory();

            m.Memento = s.SaveMemento();

            // Continue changing originator
            s.Address = "548 S Main St. Nowhere, KS";

            // Crap, gotta undo that entry, I entered the wrong address
            s.RestoreMemento(m.Memento);

            Console.ReadKey();
        }