Example #1
0
        public static HeWeatherModel Generate(string resstr, DataSource dataSource)
        {
            switch (dataSource)
            {
            case DataSource.HeWeather:
                var he = HeWeatherContract.Generate(resstr);
                try
                {
                    return(new HeWeatherModel(he));
                }
                catch (Exception)
                {
                    return(null);
                }

            case DataSource.Caiyun:
                var cai = CaiyunContract.Generate(resstr);
                return(new HeWeatherModel(cai.now, cai.forecast));

            case DataSource.Wunderground:
                var wun = WunderGroundContract.Generate(resstr);
                return(new HeWeatherModel(wun));

            default:
                return(null);
            }
        }
Example #2
0
 private static HeWeatherStatus ParseStatus_W(WunderGroundContract w)
 {
     if (w != null && w.response != null && w.current_observation != null)
     {
         return(HeWeatherStatus.ok);
     }
     else
     {
         return(HeWeatherStatus.no_response);
     }
 }
Example #3
0
 public HeWeatherModel(WunderGroundContract wun)
 {
     if (null == wun)
     {
         return;
     }
     Status         = ParseStatus_W(wun);
     NowWeather     = new NowWeather(wun.current_observation);
     DailyForecast  = GenerateDailyForecast(wun.forecast.simpleforecast.forecastday);
     HourlyForecast = GenerateHourlyForecast(wun.hourly_forecast);
     Location       = new Location(wun.current_observation);
 }