예제 #1
0
파일: Program.cs 프로젝트: qq21/DesignModel
        /// <inheritdoc />
        protected Observer(ISubject subject, string name)
        {
            this.subject = subject;
            this.name    = name;

            //无法在构造函数里 直接添加观察者 但是 可以 利用委托 做到
            //   this.subject.AddObserver(this);
            //利用委托
            WeatherNoticeEvent ShWNE = new WeatherNoticeEvent(Update);

            subject.AddListner(ShWNE);
        }