Web client used to handle API compression.
Наследование: System.Net.WebClient
Пример #1
0
        /// <summary>
        /// Actually performs a request against the API, and returns the response object.
        /// </summary>
        /// <typeparam name="T">The strong type of the expected API result against which to deserialize JSON.</typeparam>
        /// <param name="endpoint">The API endpoint to query.</param>
        /// <returns>The API response object.</returns>
        private IApiResponse <T> PerformRequest <T>(string endpoint) where T : class
        {
            Client.EventLog.InfoFormat(Events.ApiRequest, endpoint);
            Interlocked.Increment(ref _totalRequests);
            Interlocked.Increment(ref _concurrentRequests);
            string responseText;

            using (WebClient client = new ApiWebClient())
            {
                responseText = client.DownloadString(endpoint);
            }
            Interlocked.Decrement(ref _concurrentRequests);
            IApiResponse <T> result = responseText.DeserializeJson <ApiResponse <T> >();

            result.Dynamic = responseText.DeserializeJson();
            result.Source  = ResultSourceEnum.Api;
            return(result);
        }