/// <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); }
/// <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); }
/// <summary> /// Notifies all observers. /// </summary> protected virtual void OnNewMail(WeatherInfoEventArgs info) { NewMail?.Invoke(this, info); }
/// <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);