Exemple #1
0
            public Driver()
            {
                // The client code.
                var subject   = new Subject();
                var observerA = new ConcreteObserverA();

                subject.Attach(observerA);
                var observerB = new ConcreteObserverB();

                subject.Attach(observerB);

                subject.SomeBusinessLogic();
                subject.SomeBusinessLogic();

                subject.Detach(observerB);

                subject.SomeBusinessLogic();
            }
        static void Main(string[] args)
        {
            // The client code.
            var subject   = new Subject();
            var observerA = new ConcreteObserverA();

            subject.Attach(observerA);

            var observerB = new ConcreteObserverB();

            subject.Attach(observerB);

            subject.SomeBusinessLogic();
            subject.SomeBusinessLogic();

            subject.Detach(observerB);

            subject.SomeBusinessLogic();
        }