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
- object
- HttpContent
- XmlContent
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
payloadobject- The object to be serialized into XML format.
Exceptions
- ArgumentNullException
- Thrown if
payloadisnull.
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
contentobject- The object to be serialized into XML format.
encodingEncoding- The character encoding to use for the serialized XML content.
Exceptions
- ArgumentNullException
- Thrown if
contentorencodingisnull.
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
streamStream- The target stream.
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.
