Example #1
0
        private StringContent BindBodyContent(MethodInfo method, ParameterInfo parameter, object[] args)
        {
            var value = args[parameter.Position];

            string json = JsonConvert.SerializeObject(value, ApiSerializerSettings.Configure());

            return(new StringContent(json, Encoding.UTF8, "application/json"));
        }
Example #2
0
        private async Task <T> ParseSuccessfulResponseAsync <T>(HttpResponseMessage response, MethodInfo method)
        {
            string raw = await response.Content.ReadAsStringAsync();

            //T result = default(T); //any reason to do this?

            var result = JsonConvert.DeserializeObject <T>(raw, ApiSerializerSettings.Configure());

            return(result);
        }
Example #3
0
        // ParseSuccessfulResponse reads out the response content to a string
        // and deserializes it back to object (if necessary to do so)

        #region ParseSuccessfulResponse, ParseSuccessfulResponseAsync<T>

        private object ParseSuccessfulResponse(HttpResponseMessage response, MethodInfo method)
        {
            if (method.ReturnType == typeof(void))
            {
                return(null);
            }

            string raw = response.Content.ReadAsStringAsync()
                         .GetAwaiter().GetResult();

            object result = null;

            result = JsonConvert.DeserializeObject(raw, method.ReturnType, ApiSerializerSettings.Configure());

            return(result);
        }