/// <summary> /// Get weather data instance /// </summary> /// <param name="location">receive location object as parameter</param> /// <returns>returns the instance </returns> public WeatherData getWeatherData(Location location) { if (location != null) { init(location);// init forecast } else throw new WeatherDataServiceException("No location set"); return weatherData; }
// init data /// <summary> /// Init database , download from web service API and load data from file database /// </summary> private void init(Location location) { DownloadXmlToDataBase(location.City, location.State);//download from API locationForecast = new Forecast(loadData(location.City, location.State));//allocate forecast }
/// <summary> /// initForecastObjects init and allocate all forecast objects /// </summary> private void initForecastObjects() { this.location = new Location(); this.sunRise = new SunRise(); this.temperature = new Temperature(); this.humidity = new Humidity(); this.pressure = new Pressure(); this.windSpeed = new WindSpeed(); this.windDirection = new WindDirection(); this.clouds = new Clouds(); this.precipitation = new Precipitation(); this.weather = new Weather(); this.lastupdate = new Lastupdate(); }