/// <summary> /// Parses an array of strings into a Location instance /// </summary> /// <param name="properties">The array of string properties to parse from</param> /// <returns>The parsed Location instance, or null if not parsable</returns> private Location ParseToLocation(string[] properties) { Location location = null; try { if (properties.Length != 3) throw new Exception("Location source string is not in the expected format."); string name = properties[0]; double lat = double.Parse(properties[1]); double lon = double.Parse(properties[2]); location = new Location(name, lat, lon); } catch (Exception) { // todo: logging... } return location; }
/// <summary> /// Attempts to get a forecast for a location /// </summary> /// <param name="location">The location to get the forecast for</param> /// <returns>The forecast for the location, or null if not found</returns> private Forecast GetForecastForLocation(Location location) { Forecast forecast = null; if (location != null) { try { forecast = _weatherForecastService.GetForecastByCoords(_selectedLocation.Lat, _selectedLocation.Lon); } catch (Exception) { // todo: log } } return forecast; }