예제 #1
0
        /// <summary>

        /// Entry point into console application.

        /// </summary>

        public static void Demonstrate()
        {
            // Configure Observer pattern

            ConcreteSubject s = new ConcreteSubject();

            s.Attach(new ConcreteObserver(s, "X"));
            s.Attach(new ConcreteObserver(s, "Y"));
            s.Attach(new ConcreteObserver(s, "Z"));

            // Change subject and notify observers

            s.SubjectState = "ABC";
            s.Notify();

            // Wait for user

            Console.ReadKey();
        }
예제 #2
0
 public ConcreteObserver(ConcreteSubject subject, string name)
 {
     Subject = subject;
     _name   = name;
 }
예제 #3
0
 public ConcreteObserver(ConcreteSubject sub)
 {
     subject = sub;
 }
예제 #4
0
        // Constructor

        public ConcreteObserver(
            ConcreteSubject subject, string name)
        {
            this._subject = subject;
            this._name    = name;
        }