public void Unsubscribe(TemperatureReporter observer)
 {
     if (observers.Contains(observer))
     {
         this.observers.Remove(observer);
     }
 }
 public void Subscribe(TemperatureReporter observer)
 {
     if (!observers.Contains(observer))
     {
         observers.Add(observer);
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            TemperatureSensor   monitor  = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            reporter.StartReporting(monitor);
            monitor.Notify();
        }
예제 #4
0
        static void Main(string[] args)
        {
            TemperatureSensor   sensor   = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            reporter.StartReporting(sensor);
            sensor.GetTemperature();
        }
예제 #5
0
        public static void Main(string[] args)
        {
            TemperatureReporter tempRep = new TemperatureReporter(); //Observador
            TemperatureMonitor  tempMon = new TemperatureMonitor();  //Proveedor

            tempRep.Subscribe(tempMon);
            tempMon.GetTemperature();
        }
예제 #6
0
        static void Main(string[] args)
        {
            TemperatureSensor   sensor    = new TemperatureSensor();
            TemperatureReporter reporter  = new TemperatureReporter();
            DateTime            localDate = DateTime.Now;
            Temperature         a         = new Temperature(20, localDate);;

            sensor.GetTemperature();
        }
예제 #7
0
        static void Main(string[] args)
        {
            TemperatureSensor   monitor  = new TemperatureSensor();
            TemperatureReporter reporter = new TemperatureReporter();

            monitor.Subscribe(reporter);
            reporter.StartReporting();
            monitor.GetTemperature();
        }