예제 #1
0
        public ForecastIOResponse Get()
        {
            var url = (time == null) ? String.Format(currentForecastURL, apiKey, latitude, longitude, unit, exclude) :
                String.Format(periodForecastURL, apiKey, latitude, longitude, time, unit, exclude);

            string result;
            using (CompressionEnabledWebClient client = new CompressionEnabledWebClient())
            {
                result = RequestHelpers.FormatResponse(client.DownloadString(url));
            }

            var serializer = new JavaScriptSerializer();
            var dataObject = serializer.Deserialize<ForecastIOResponse>(result);

            return dataObject;
        }
예제 #2
0
        public ForecastIOResponse Get()
        {
            var url = (time == null) ? String.Format(currentForecastURL, apiKey, latitude, longitude, unit, exclude) :
                      String.Format(periodForecastURL, apiKey, latitude, longitude, time, unit, exclude);

            string result;

            using (CompressionEnabledWebClient client = new CompressionEnabledWebClient())
            {
                result = RequestHelpers.FormatResponse(client.DownloadString(url));
            }

            var serializer = new JavaScriptSerializer();
            var dataObject = serializer.Deserialize <ForecastIOResponse>(result);

            return(dataObject);
        }
예제 #3
0
        public ForecastIOResponse Get()
        {
            var url = (_time == null) ? String.Format(CurrentForecastUrl, _apiKey, _latitude, _longitude, _unit, _extend, _exclude) :
                      String.Format(PeriodForecastUrl, _apiKey, _latitude, _longitude, _time, _unit, _extend, _exclude);

            string result;

            using (var client = new CompressionEnabledWebClient())
            {
                result = RequestHelpers.FormatResponse(client.DownloadString(url));
                // Set response values.
                _apiResponseTime = client.ResponseHeaders["X-Response-Time"];
                _apiCallsMade    = client.ResponseHeaders["X-Forecast-API-Calls"];
            }

            var serializer = new JavaScriptSerializer();
            var dataObject = serializer.Deserialize <ForecastIOResponse>(result);

            return(dataObject);
        }
        public ForecastIOResponse Get()
        {
            var url = (_time == null) ? String.Format(CurrentForecastUrl, _apiKey, _latitude, _longitude, _unit, _extend, _exclude) :
                String.Format(PeriodForecastUrl, _apiKey, _latitude, _longitude, _time, _unit, _extend, _exclude);

            string result;
            using (var client = new CompressionEnabledWebClient())
            {
                result = RequestHelpers.FormatResponse(client.DownloadString(url));
                // Set response values.
                _apiResponseTime = client.ResponseHeaders["X-Response-Time"];
                _apiCallsMade = client.ResponseHeaders["X-Forecast-API-Calls"];
            }

            var serializer = new JavaScriptSerializer();
            var dataObject = serializer.Deserialize<ForecastIOResponse>(result);

            return dataObject;

        }