예제 #1
0
 /// <summary>
 ///     Extension method reading the httpContent to a Typed object, depending on the returned content-type
 ///     Currently we support:
 ///     Json objects which are annotated with the DataContract/DataMember attributes
 /// </summary>
 /// <typeparam name="TResult">The Type to read into</typeparam>
 /// <param name="httpContent">HttpContent</param>
 /// <param name="httpStatusCode">HttpStatusCode</param>
 /// <param name="cancellationToken">CancellationToken</param>
 /// <returns>the deserialized object of type T</returns>
 public static async Task <TResult> GetAsAsync <TResult>(this HttpContent httpContent, HttpStatusCode httpStatusCode,
                                                         CancellationToken cancellationToken = default(CancellationToken)) where TResult : class
 {
     return((TResult)await httpContent.GetAsAsync(typeof(TResult), httpStatusCode, cancellationToken).ConfigureAwait(false));
 }