public OberverPattern()
        {
            ConcreteSubject s=new ConcreteSubject();
            s.Attach(new ConcreteObserver(s, "a"));
            s.Attach(new ConcreteObserver(s, "b"));
            s.Attach(new ConcreteObserver(s, "c"));

            s.Attach(new TwoConcreteObserver(s, "stop"));

            s.SubjectState = "run";
            s.Notify();
            s.SubjectState = "stop";
            s.Notify();

            //用委托的方式
            var one = new ConcreteObserver(s, "a");
            var two = new TwoConcreteObserver(s, "b");

            var de=new DelegetSubject();
            de.Up += new DelegetSubject.EventHand(one.TestOneDelegate);
            de.Up += new DelegetSubject.EventHand(two.TestDelegate);
            de.Notify();
        }
 public ConcreteObserver(ConcreteSubject subject,string name)
 {
     this.subject = subject;
     this.name = name;
 }
 public TwoConcreteObserver(ConcreteSubject concreteTest, string name)
 {
     this.concreteTest = concreteTest;
     this.name = name;
 }