Improve this Doc View Source

Class HttpContentExtensions

Extensions for the HttpContent

Inheritance
System.Object
HttpContentExtensions
Namespace:Dapplo.HttpExtensions
Assembly:Dapplo.HttpExtensions.dll
Syntax
public class HttpContentExtensions

Methods

| Improve this Doc View Source

GetAsAsync(HttpContent, Type, CancellationToken)

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

Declaration
public static Task<object> GetAsAsync(HttpContent httpContent, Type resultType, CancellationToken token = null)
Parameters
Type Name Description
System.Net.Http.HttpContent httpContent

HttpContent

System.Type resultType

The Type to read into

System.Threading.CancellationToken token

CancellationToken

Returns
Type Description
System.Threading.Tasks.Task<System.Object>

the deserialized object of type T

| Improve this Doc View Source

GetAsAsync<TResult>(HttpContent, CancellationToken)

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

Declaration
public static Task<TResult> GetAsAsync<TResult>(HttpContent httpContent, CancellationToken token = null)where TResult : class
Parameters
Type Name Description
System.Net.Http.HttpContent httpContent

HttpContent

System.Threading.CancellationToken token

CancellationToken

Returns
Type Description
System.Threading.Tasks.Task<TResult>

the deserialized object of type T

| Improve this Doc View Source

GetContentType(HttpContent)

Simply return the content type of the HttpContent

Declaration
public static string GetContentType(HttpContent httpContent)
Parameters
Type Name Description
System.Net.Http.HttpContent httpContent

HttpContent

Returns
Type Description
System.String

string with the content type

| Improve this Doc View Source

SetContentType(HttpContent, String)

Simply set the content type of the HttpContent

Declaration
public static void SetContentType(HttpContent httpContent, string contentType)
Parameters
Type Name Description
System.Net.Http.HttpContent httpContent

HttpContent

System.String contentType

Content-Type to set