예제 #1
0
        static void Main()
        {
            var subject = new ConcreteSubject();

            subject.Attach(new ConcreteObserver(subject, "Observer 1"));
            subject.Attach(new ConcreteObserver(subject, "Observer 2"));
            subject.Attach(new ConcreteObserver(subject, "Observer 3"));
            subject.SetState("STATE");
        }
예제 #2
0
        static void Main(string[] args)
        {
            ConcreteSubject cel  = new ConcreteSubject();
            ConcreteSubject cel2 = new ConcreteSubject();
            Observer        obs1 = new ConcreteObserver("Obserwator 1", cel);
            Observer        obs2 = new ConcreteObserver("Obserwator 2", cel);
            Observer        obs3 = new ConcreteObserver("Obserwator 3", cel2);
            Observer        obs4 = new ConcreteObserver("Obserwator 4", cel2);

            cel.SetState("nowy stan");
            cel2.SetState("kolejny stan");
        }
예제 #3
0
        static void Main(string[] args)
        {
            Subject subject = new ConcreteSubject("ABC");

            subject.AttachRange(new List <Observer>
            {
                new ConcreteObserver("o1"),
                new ConcreteObserver("o2"),
                new ConcreteObserver("o3")
            });

            subject.SetState("XYZ");
            Console.ReadKey();
        }
예제 #4
0
        private static void Main(string[] args)
        {
            // canonical example

            var subject = new ConcreteSubject();

            var observer1 = new ConcreteObserver(1);
            var observer2 = new ConcreteObserver(2);

            subject.Attach(observer1);
            subject.Attach(observer2);

            subject.SetState(new List <string>());
            subject.UpdateStatePartially("yoyo");
            subject.UpdateStatePartially("ahahha");
        }
예제 #5
0
 static void Main()
 {
     var subject = new ConcreteSubject();
     subject.Attach(new ConcreteObserver(subject,"Observer 1"));
     subject.Attach(new ConcreteObserver(subject,"Observer 2"));
     subject.Attach(new ConcreteObserver(subject,"Observer 3"));
     subject.SetState("STATE");
 }