示例#1
0
        static void Main(string[] args)
        {
            Subject store = new Subject();

            //client1 take a subscription to the store
            Observver client1 = new Observver("Lucian");

            store.Subscribe(client1);


            //client2 take a subscription to the store
            Observver client2 = new Observver("Alina");

            store.Subscribe(client2);
            store.Inventory++;


            Console.WriteLine("------------------------");

            //alina left the subscription but a new user subcripted to the store
            store.Unsubsribe(client2);
            store.Subscribe(new Observver("Feli"));
            store.Inventory++;

            Console.WriteLine("------------------------");

            Console.WriteLine("Hello from observer pattern");
            Console.ReadLine();
        }