Beispiel #1
0
        private static void ObserverDemo()
        {
            var ibm       = new IBM("IBM", 120.00);
            var investor1 = new Investor("Sorros");
            var investor2 = new Investor("Berkshire");

            ibm.StartWatching(investor1.Update);
            ibm.StartWatching(investor2.Update);

            ibm.UpdatePrice(120.10);
            ibm.UpdatePrice(121.00);
            ibm.StopWatching(investor1.Update);
            ibm.UpdatePrice(120.50);
            ibm.StopWatching(investor2.Update);
            ibm.UpdatePrice(120.75);
        }