Пример #1
0
        /// <summary>
        /// Generates the weather.
        /// </summary>
        public void GenerateWeather()
        {
            var random  = new Random();
            var weather = new WeatherInfoEventArgs(random.Next(30), random.Next(772, 780), random.Next(100));

            OnWeatherChange(weather);
        }
Пример #2
0
        /// <summary>
        /// Generates data and sends it to subscribers.
        /// </summary>
        public void Generate()
        {
            Random rand        = new Random();
            var    currentData = new WeatherInfoEventArgs {
                Temperature = rand.Next(40), Humidity = rand.Next(400, 500), Pressure = rand.Next(990, 1010)
            };

            OnNewMail(currentData);
        }
Пример #3
0
 /// <summary>
 /// Notifies all observers.
 /// </summary>
 protected virtual void OnNewMail(WeatherInfoEventArgs info)
 {
     NewMail?.Invoke(this, info);
 }
Пример #4
0
 /// <summary>
 /// Raises the <see cref="E:WeatherChange" /> event.
 /// </summary>
 /// <param name="info">The <see cref="WeatherInfoEventArgs"/> instance containing the event data.</param>
 protected virtual void OnWeatherChange(WeatherInfoEventArgs info) => WeatherChange?.Invoke(this, info);