Class ByteArrayHttpContentConverter
This can convert HttpContent from/to a byte[]
Inheritance
Namespace:Dapplo.HttpExtensions.ContentConverter
Assembly:Dapplo.HttpExtensions.dll
Syntax
public class ByteArrayHttpContentConverter : IHttpContentConverter
Fields
| Improve this Doc View SourceInstance
Used to create the list of available IHttpContentConverter Can also be used to access the singleton to change the settings.
Declaration
public static readonly ByteArrayHttpContentConverter Instance
Properties
| Improve this Doc View SourceOrder
Order or priority of the IHttpContentConverter
Declaration
public int Order { get; }
Returns
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAddAcceptHeadersForType(Type, HttpRequestMessage)
Add Accept-Headers to the HttpRequestMessage, depending on the passt resultType. This tries to hint the Http server what we can accept, which depends on the type of the return value
Declaration
public void AddAcceptHeadersForType(Type resultType, HttpRequestMessage httpRequestMessage)
Parameters
Type | Name | Description |
---|---|---|
System.Type | resultType | Result type, this where to a conversion from HttpContent is made |
System.Net.Http.HttpRequestMessage | httpRequestMessage | HttpRequestMessage |
CanConvertFromHttpContent(Type, HttpContent)
Check if we can convert from the HttpContent to a byte array
Declaration
public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvertTo | To what type will the result be assigned |
System.Net.Http.HttpContent | httpContent | HttpContent |
Returns
Type | Description |
---|---|
System.Boolean | true if we can convert the HttpContent to a ByteArray |
CanConvertToHttpContent(Type, Object)
Checks if the content of type typeToConvert can be converted into a HttpContent
Declaration
public bool CanConvertToHttpContent(Type typeToConvert, object content)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvert | Type to convert to |
System.Object | content | some object |
Returns
Type | Description |
---|---|
System.Boolean | true if a conversion can be made |
ConvertFromHttpContentAsync(Type, HttpContent, CancellationToken)
Convert a HttpContent to the specified type
Declaration
public Task<object> ConvertFromHttpContentAsync(Type resultType, HttpContent httpContent, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
System.Type | resultType | Type to convert to |
System.Net.Http.HttpContent | httpContent | HttpContent |
System.Threading.CancellationToken | token | CancellationToken, used as the HttpContent might be read async |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Task with result |
ConvertToHttpContent(Type, Object)
Actually convert the passed object into a HttpContent
Declaration
public HttpContent ConvertToHttpContent(Type typeToConvert, object content)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvert | Type to convert from |
System.Object | content | Some object |
Returns
Type | Description |
---|---|
System.Net.Http.HttpContent | HttpContent |