예제 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Classic Observer");

            var ticker    = new StockTicker();
            var google    = new GoogleObserver(ticker);
            var microsoft = new MicrosoftObserver(ticker);

            foreach (var item in SampleData.GetNext())
            {
                ticker.Stock = item;
            }

            Console.WriteLine();
            Console.WriteLine("Event and Delegates");

            var stockTicker      = new Events.StockTicker();
            var googleMonitor    = new GoogleMonitor(stockTicker);
            var microsoftMonitor = new MicrosoftMonitor(stockTicker);

            foreach (var item in SampleData.GetNext())
            {
                stockTicker.Stock = item;
            }

            Console.ReadKey();
        }
예제 #2
0
        private static void TraditionalObserver()
        {
            var               subj = new TraditionalObs.StockTicker();
            GoogleObserver    gobs = new GoogleObserver(subj);
            MicrosoftObserver mobs = new MicrosoftObserver(subj);

            foreach (var s in SampleData.getNext())
            {
                subj.Stock = s;
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            StockTicker subject = new StockTicker();

            GoogleObserver    gobs = new GoogleObserver(subject);
            MicrosoftObserver mobs = new MicrosoftObserver(subject);
            NokiaObserver     nobs = new NokiaObserver(subject);

            foreach (var s in SampleData.getNext())
            {
                subject.Stock = s;
            }

            Console.ReadLine();
        }