Exemple #1
0
		static void Main(string[] args) {
			var o1 = new Observer();
			var o2 = new Observer();
			var s1 = new Subject();

			s1.RegisterObserver(o1);
			s1.RegisterObserver(o2);
			s1.NotifyObserver(new SubjectData { RC = 0, Msg = "OK" });
		}
        static void Main(string[] args)
        {
            var observerA = new ConcreteObserverA();
            var observerB = new ConcreteObserverB();
            var subject   = new Subject();

            subject.RegisterObserver(observerA);
            subject.RegisterObserver(observerB);
            subject.NotifyObservers();
            Console.WriteLine("--------------------");
            subject.UnregisterObserver(observerA);
            subject.NotifyObservers();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Subject   subject = new Subject();
            IObserver display = new Display();
            IObserver dips1   = new DisplayNew();

            subject.RegisterObserver(dips1);
            subject.RegisterObserver(display);

            subject.SetMeasurement((float)10.2, (float)11.2, (float)13.2);

            subject.RemoveObserver(display);

            subject.SetMeasurement((float)7.2, (float)8.2, (float)9.2);
        }
 public AwfulForecastDisplay(Subject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
 public CurrentConditionsDisplay(Subject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
Exemple #6
0
        static void Main(string[] args)
        {
            Subject subject = new Subject();
            IObserver display = new Display();
            IObserver dips1 = new DisplayNew();
            subject.RegisterObserver(dips1);
            subject.RegisterObserver(display);

            subject.SetMeasurement((float)10.2, (float)11.2, (float)13.2);

            subject.RemoveObserver(display);

            subject.SetMeasurement((float)7.2, (float)8.2, (float)9.2);
        }
Exemple #7
0
 public ForcastDisply(Subject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
Exemple #8
0
 public StaisticsDisply(Subject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
Exemple #9
0
 public CurrentConditonsDisplay(Subject subject)
 {
     Subject = subject;
     Subject.RegisterObserver(this);
 }