コード例 #1
0
        public void IObserverTest()
        {
            //Monitor a stock ticker, when particular events occur, react
            OI.StockTicker subject = new OI.StockTicker();

            // Load the Sample Stock Data
            using (subject.Subscribe(new OI.MicrosoftObserver()))
                using (subject.Subscribe(new OI.GoogleObserver()))
                {
                    foreach (var s in SampleData.getNext())
                    {
                        subject.Stock = s;
                    }
                }
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            // Monitor a stock ticker, when particular events occur, react
            StockTicker st = new StockTicker();

            GoogleMonitor    gf = new GoogleMonitor();
            MicrosoftMonitor mf = new MicrosoftMonitor();

            using (st.Subscribe(gf))
                using (st.Subscribe(mf))
                {
                    // Load the Sample Stock Data
                    foreach (var s in SampleData.getNext())
                    {
                        st.Stock = s;
                    }
                }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            //EventKeyWord();

            //TraditionalObserver();

            // Monitor a stock ticker, when particular events occur, react
            var st = new IObserver.StockTicker();

            GoogleMonitor    gf = new GoogleMonitor();
            MicrosoftMonitor mf = new MicrosoftMonitor();

            using (st.Subscribe(gf))
                using (st.Subscribe(mf))
                {
                    // Load the Sample Stock Data
                    foreach (var s in SampleData.getNext())
                    {
                        st.Stock = s;
                    }
                }
        }