示例#1
0
 public Observer(Subject subject, string name, string gap)
 {
     this.subject = subject;
     this.name = name;
     this.gap = gap;
     subject.Notify += Update;
 }
示例#2
0
文件: Main.cs 项目: Aleksandar7kr/ETU
 static void Main(string[] args)
 {
     Subject subject = new Subject();
     Observer Observer = new Observer(subject, "Center", "\t\t");
     Observer observer2 = new Observer(subject, "Right", "\t\t\t\t");
     subject.Go();
     Console.Read();
 }
示例#3
0
 static void Main(string[] args)
 {
     Subject subject = new Subject(5);
     // Observer1 takes a subscription to the store
     var observer1 = new Observar("Observer 1");
     subject.Subscribe(observer1);
     // Observer2 also subscribes to the store
     subject.Subscribe(new Observar("Observer 2"));
     subject.Data++;
     // Observer1 unsubscribes and Observer3 subscribes to notifications.
     subject.Unsubscribe(observer1);
     subject.Subscribe(new Observar("Observer 3"));
     subject.Data++;
     Console.ReadLine();
 }
示例#4
0
 public override void Update(Subject s)
 {
     Console.WriteLine("{0} observed that {1} changed", GetType().Name, s.GetType().Name);
 }
示例#5
0
 public abstract void Update(Subject s);
示例#6
0
文件: Program.cs 项目: rhdlmv/Jimi
 public CurrentConditionsDisplay(Subject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
示例#7
0
 public ThirdPartyDisplay(Subject weatherData)
 {
     this.WeatherData = weatherData;
     this.WeatherData.RegisterObserver(this);
 }
示例#8
0
 public HeatIndexDisplay(Subject s)
 {
     weatherData = s;
     weatherData.RegisterObserver(this);
 }
示例#9
0
 public CurrentConditionsDisplay(Subject s)
 {
     weatherData = s;
     weatherData.RegisterObserver(this);
 }
示例#10
0
 public StatisticsDisplay(Subject s)
 {
     weatherData = s;
     weatherData.RegisterObserver(this);
 }
示例#11
0
 public ForecastDisplay(Subject weatherData)
 {
     this.WeatherData = weatherData;
     WeatherData.RegisterObserver(this);
 }
示例#12
0
 public StatisticsDisplay(Subject weatherData)
 {
     this.WeatherData = weatherData;
     this.WeatherData.RegisterObserver(this);
 }