Example #1
0
 /// <summary>
 /// Reads a DTO from the specified HTTP content.
 /// </summary>
 protected override async Task <ServiceResult <object> > ReadHttpContentAsyncCore(Type dtoType, HttpContent content, CancellationToken cancellationToken)
 {
     try
     {
         using (var stream = await content.ReadAsStreamAsync().ConfigureAwait(false))
             using (var textReader = new StreamReader(stream))
                 return(ServiceResult.Success(ServiceJsonUtility.FromJsonTextReader(textReader, dtoType)));
     }
     catch (JsonException exception)
     {
         return(ServiceResult.Failure(HttpServiceErrors.CreateInvalidContent(exception.Message)));
     }
 }