Example #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();
            }
Example #2
0
        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();
        }