NewtonsoftJsonContent Class
- Namespace
- Kampute.HttpClient.NewtonsoftJson
- Assembly
- Kampute.HttpClient.NewtonsoftJson.dll
Definition
Represents
application/json content that serializes an object with Newtonsoft.Json when it is sent.public sealed class NewtonsoftJsonContent : HttpContent- Inheritance
- object
- HttpContent
- NewtonsoftJsonContent
Constructors
NewtonsoftJsonContent(object)
Initializes a new instance of the NewtonsoftJsonContent class.
public NewtonsoftJsonContent(object content)Parameters
contentobject- The object to serialize.
Exceptions
- ArgumentNullException
- Thrown if
contentisnull.
Properties
Settings
Gets or sets the serializer settings.
public JsonSerializerSettings Settings { get; set; }Property Value
- JsonSerializerSettings
- The settings used to serialize the object, or
nullfor the defaults of the serializer.
Methods
SerializeToStreamAsync(Stream, TransportContext)
Writes the object to a stream as JSON.
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)Parameters
streamStream- The stream to write to.
contextTransportContext- The transport context.
Returns
- Task
- A task that represents the asynchronous operation.
TryComputeLength(out long)
Attempts to compute the length of the content.
protected override bool TryComputeLength(out long length)Parameters
lengthlong- When this method returns, contains the length of the content in bytes.
Returns
Extension Methods
| AsDeflate(this HttpContent, CompressionLevel) | Wraps the content in content that compresses it with Deflate as it is sent. |
| AsGzip(this HttpContent, CompressionLevel) | Wraps the content in content that compresses it with GZip as it is sent. |
| FindCharacterEncoding(this HttpContent) | Returns the character encoding named by the charset parameter of the Content-Type header. |
| IsReusable(this HttpContent) | Determines whether the content can be sent more than once, as a retry requires. |
