public ForecaWeather(ForecaCurrentWeather currentWeather, List<ForecaForecastWeather> forecasts) { if (currentWeather == null) throw new ArgumentNullException(nameof(currentWeather)); if (forecasts == null) throw new ArgumentNullException(nameof(forecasts)); this.CurrentWeather = currentWeather; this.Forecasts = forecasts; }
private static ForecaCurrentWeather ParseCurrent(XElement root) { var current = new ForecaCurrentWeather(); current.LocationId = root.Attribute(XName.Get(@"id")).Value; var city = root.Attribute(XName.Get(@"name")).Value; var country = root.Attribute(XName.Get(@"country")).Value; current.Point = city + @", " + country; var currentValues = root.Descendants(XName.Get(@"cc")).SingleOrDefault(); if (currentValues != null) { current.Date = DateTime.Parse(currentValues.Attribute(XName.Get(@"dt")).Value); current.Temperature = GetDoubleValue(currentValues.Attribute(XName.Get(@"t")).Value); current.IconCode = ParseIcon(currentValues.Attribute(XName.Get(@"s")).Value); current.Description = currentValues.Attribute(XName.Get(@"station")).Value; current.Feelslike = GetDoubleValue(currentValues.Attribute(XName.Get(@"tf")).Value); current.Humidity = GetDoubleValue(currentValues.Attribute(XName.Get(@"rh")).Value); } return current; }