public async Task <TReturnType> BuildRequest <TReturnType>(string url, int timeoutSeconds, params KeyValuePair <string, object>[] parameters)
        {
            var result = await DoGet(url, timeoutSeconds, parameters);

            Debug.WriteLine(result);

            try
            {
                return(_requestSerializer.DeserializeObject <TReturnType>(result));
            }
            catch (JsonSerializationException)
            {
                // retry as an array
                return(_requestSerializer.DeserializeObject <IEnumerable <TReturnType> >(result).First());
            }
        }
Exemple #2
0
        public async Task <TReturnType> BuildRequest <TReturnType>(string url, int timeoutSeconds, params KeyValuePair <string, object>[] parameters)
        {
            var result = await MakeRequest(url, timeoutSeconds, parameters);

            var stringResult = await result.Content.ReadAsStringAsync();

            Debug.WriteLine(stringResult);

            return(_requestSerializer.DeserializeObject <TReturnType>(stringResult));
        }
        public async Task <TReturnType> BuildRequest <TReturnType>(string url, int timeoutSeconds, params KeyValuePair <string, object>[] parameters)
        {
            var request = new HttpClient {
                Timeout = new TimeSpan(0, 0, timeoutSeconds)
            };
            Uri uri = new Uri(url);

            uri = new Uri(uri + _methodName.ToLower());

            if (parameters.Any())
            {
                uri = UriBuildingHelpers.AttachParameters(uri, parameters.Where(x => x.Key != null && x.Value != null).Select(x => new KeyValuePair <string, string>(x.Key, x.Value.ToString())).ToArray());
            }

            var result = await request.DeleteAsync(uri);

            var stringResult = await result.Content.ReadAsStringAsync();

            Debug.WriteLine(stringResult);

            return(_requestSerializer.DeserializeObject <TReturnType>(stringResult));
        }