コード例 #1
0
        protected ApiResponseResult <T> ApiResponseResult <T>(string body, HttpStatusCode code) where T : BaseResponse
        {
            try
            {
                var response = JsonConvert.DeserializeObject <T>(body);
                if (response == null)
                {
                    throw new HttpRequestException(string.Empty);
                }

                return(response.Code == ResponseCodes.OkResponse
                    ? Api.ApiResponseResult <T> .Ok(response)
                    : Api.ApiResponseResult <T> .Fail(response, code, response.Error));
            }
            catch (JsonException)
            {
                throw new HttpRequestException(code.Description());
            }
        }
コード例 #2
0
        protected ApiResponseResult <T> ApiResponseResult <T>(string body, HttpStatusCode code)
            where T : BaseResponse
        {
            try
            {
                T response = JsonConvert.DeserializeObject <T>(body);
                if (response == null)
                {
                    throw new HttpRequestException(string.Empty);
                }

                ApiResponseResult <T> result = CreateApiResponseResult(response, code);
                HandleResult(result);
                return(result);
            }
            catch (JsonException)
            {
                throw new HttpRequestException(code.Description());
            }
        }