XmlContent Class

Namespace
Kampute.HttpClient.DataContract
Assembly
  • Kampute.HttpClient.DataContract.dll

Definition

Represents HTTP content based on XML serialized from an object.
public sealed class XmlContent : HttpContent
Inheritance

Constructors

XmlContent(object)

Initializes a new instance of the XmlContent class using a specified content object with UTF-8 encoding.
public XmlContent(object payload)

Parameters

payload object
The object to be serialized into XML format.

Exceptions

ArgumentNullException
Thrown if payload is null.

XmlContent(object, Encoding)

Initializes a new instance of the XmlContent class using a specified content object and encoding.
public XmlContent(object content, Encoding encoding)

Parameters

content object
The object to be serialized into XML format.
encoding Encoding
The character encoding to use for the serialized XML content.

Exceptions

ArgumentNullException
Thrown if content or encoding is null.

Properties

Encoding

Gets the character encoding of the serialized XML content.
public Encoding Encoding { get; }

Property Value

Encoding
The character encoding of the serialized XML content.

Settings

Gets or sets the XML serialization settings.
public DataContractSerializerSettings Settings { get; set; }

Property Value

DataContractSerializerSettings
The XML serialization settings, if any.

Methods

SerializeToStreamAsync(Stream, TransportContext)

Serializes the content to a stream asynchronously.
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)

Parameters

stream Stream
The target stream.
context TransportContext
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

length long
When this method returns, contains the length of the content in bytes.

Returns

bool
true if the length could be computed; otherwise, false.