Exemple #1
0
        static void Main(string[] args)
        {
            ISubject sub = new Subject();
            ObserverA observerA = new ObserverA(sub);
            ObserverB observerB = new ObserverB(sub);
            sub.UpdateEvent += observerA.UpdateA;
            sub.UpdateEvent += observerB.UpdateB;

            sub.State = "Hello";
            sub.Notify();
            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ISubject  sub       = new Subject();
            ObserverA observerA = new ObserverA(sub);
            ObserverB observerB = new ObserverB(sub);

            sub.UpdateEvent += observerA.UpdateA;
            sub.UpdateEvent += observerB.UpdateB;

            sub.State = "Hello";
            sub.Notify();
            Console.ReadLine();
        }