Class DefaultJsonHttpContentConverter
This can convert HttpContent from/to Json TODO: add JsonObject from SimpleJson for more clear generic code..
Inheritance
System.Object
DefaultJsonHttpContentConverter
Implements
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Dapplo.HttpExtensions.JsonSimple
Assembly: Dapplo.HttpExtensions.JsonSimple.dll
Syntax
public class DefaultJsonHttpContentConverter : IHttpContentConverter
Properties
| Improve this Doc View SourceAppendedWhenCut
If the json content is any longer than LogThreshold AppendedWhenCut is appended to the cut string
Declaration
public string AppendedWhenCut { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Instance
Instance of this IHttpContentConverter for reusing
Declaration
public static Lazy<DefaultJsonHttpContentConverter> Instance { get; }
Property Value
Type | Description |
---|---|
System.Lazy<DefaultJsonHttpContentConverter> |
LogThreshold
This is the amount of characters that are written to the log, if the json content is any longer that it will be cut (and AppendedWhenCut is appended)
Declaration
public int LogThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Order
Specify the order in that this IHttpContentConverter is used
Declaration
public int Order { get; }
Property Value
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)
Declaration
public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvertTo | |
System.Net.Http.HttpContent | httpContent |
Returns
Type | Description |
---|---|
System.Boolean |
CanConvertToHttpContent(Type, Object)
Declaration
public bool CanConvertToHttpContent(Type typeToConvert, object content)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvert | |
System.Object | content |
Returns
Type | Description |
---|---|
System.Boolean |
ConvertFromHttpContentAsync(Type, HttpContent, CancellationToken)
Declaration
public async Task<object> ConvertFromHttpContentAsync(Type resultType, HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Type | resultType | |
System.Net.Http.HttpContent | httpContent | |
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> |
ConvertToHttpContent(Type, Object)
Declaration
public HttpContent ConvertToHttpContent(Type typeToConvert, object content)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvert | |
System.Object | content |
Returns
Type | Description |
---|---|
System.Net.Http.HttpContent |