Example #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();
        }
Example #2
0
 public ConcreteObserver(ConcreteSubject subject, string name)
 {
     Subject = subject;
     _name   = name;
 }
Example #3
0
 public ConcreteObserver(ConcreteSubject sub)
 {
     subject = sub;
 }
Example #4
0
        // Constructor

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