/// <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(); }
public ConcreteObserver(ConcreteSubject subject, string name) { Subject = subject; _name = name; }
public ConcreteObserver(ConcreteSubject sub) { subject = sub; }
// Constructor public ConcreteObserver( ConcreteSubject subject, string name) { this._subject = subject; this._name = name; }