예제 #1
0
        static void Main(string[] args)
        {
            Classic.PushModel.ConcreteSubject subjectPushModel = new Classic.PushModel.ConcreteSubject();
            subjectPushModel.Attach(new Classic.PushModel.ConcreteObserver(subjectPushModel));
            subjectPushModel.Attach(new Classic.PushModel.ConcreteObserver(subjectPushModel));
            subjectPushModel.State = "Some State ...";
            subjectPushModel.Notify();
            Console.WriteLine();

            Classic.PullModel.ConcreteSubject subjectPullModel = new Classic.PullModel.ConcreteSubject();
            subjectPullModel.Attach(new Classic.PullModel.ConcreteObserver(subjectPullModel));
            subjectPullModel.Attach(new Classic.PullModel.ConcreteObserver(subjectPullModel));
            subjectPullModel.State = "Some State ...";
            subjectPullModel.Notify();
            Console.WriteLine();

            LanguageSpecific.Subject  subject  = new LanguageSpecific.ConcreteSubject();
            LanguageSpecific.Observer observer = new LanguageSpecific.Observer((observerState) => Console.WriteLine(observerState + " 1"));
            subject.Event += observer;
            subject.Event += (observerState) => Console.WriteLine(observerState + " 2");
            subject.State  = "State ...";
            subject.Notify();

            Console.ReadLine();
        }
예제 #2
0
 public ConcreteObserver(ConcreteSubject subject)
 {
     this.subject = subject;
 }