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"); }
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"); }
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(); }
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"); }
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"); }