Detach() public method

public Detach ( Observer observer ) : void
observer Observer
return void
示例#1
0
        static void Main(string[] args)
        {
            // Observer Concept
            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();

            //Exercice 1
            var estacion = new EstacionMetereologica();
            var dipositivoTemperatura = new DispositivoTiempoActual();

            estacion.Attach(dipositivoTemperatura);
            for (int i = 0; i < 10; i++)
            {
                estacion.medidasHanCambiado();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var subject         = new Subject();
            var firstSubscriber = new FirstObserver();

            subject.Attach(firstSubscriber);

            var secondSubscriber = new SecondObserver();

            subject.Attach(secondSubscriber);

            subject.BusinessLogic();
            subject.BusinessLogic();

            subject.Detach(secondSubscriber);

            subject.BusinessLogic();
        }
示例#3
0
        static void Main(string[] args)
        {
            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();
            Console.ReadLine();
        }
示例#4
0
文件: Program.cs 项目: alisherKAK/DP
        static void Main(string[] args)
        {
            // Клиентский код.
            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();
        }
示例#6
0
        private static void OneThread()
        {
            var subject       = new Subject();
            var observerFirst = new FirstObserver();

            subject.Attach(observerFirst);

            subject.Notify();

            var observerSecond = new SecondObserver();

            subject.Attach(observerSecond);
            subject.Attach(observerSecond);

            subject.Notify();

            subject.Detach(observerSecond);

            subject.Notify();
        }