XmlContentDeserializer Class
- Namespace
- Kampute.HttpClient.DataContract
- Assembly
- Kampute.HttpClient.DataContract.dll
Definition
Provides functionality for deserializing XML content from HTTP responses into objects.
public sealed class XmlContentDeserializer : HttpContentDeserializer- Inheritance
- object
- HttpContentDeserializer
- XmlContentDeserializer
Constructors
XmlContentDeserializer()
Initializes a new instance of the XmlContentDeserializer class.
public XmlContentDeserializer()Properties
Settings
Gets or sets the XML deserialization settings.
public DataContractSerializerSettings Settings { get; set; }Property Value
- DataContractSerializerSettings
- The XML deserialization settings, if any.
Methods
CanDeserialize(string, Type)
Determines whether this deserializer can handle data of a specific content type and deserialize it into the specified model type.
public override bool CanDeserialize(string mediaType, Type modelType)Parameters
mediaTypestring- The media type of the content.
modelTypeType- The target model type for deserialization.
Returns
DeserializeAsync(HttpContent, Type, CancellationToken)
Asynchronously reads an object from the provided HttpContent.
public override Task<object> DeserializeAsync(HttpContent content, Type modelType, CancellationToken cancellationToken = default)Parameters
contentHttpContent- The HttpContent to read from.
modelTypeType- The type of the object to read.
cancellationTokenCancellationToken optional- A token for canceling the read operation (optional).
Returns
- Task<object>
- A task representing the asynchronous read operation, containing the deserialized object.
Exceptions
- ArgumentNullException
- Thrown if
contentormodelTypeisnull.
GetSupportedMediaTypes(Type)
Retrieves a collection of supported media types for a specific model type.
public override IEnumerable<string> GetSupportedMediaTypes(Type modelType)Parameters
modelTypeType- The type of the model for which to retrieve supported media types.
Returns
- IEnumerable<string>
- The read-only collection of media types that this deserializer supports if the model type is not
nulland is marked with a T:System.Runtime.Serialization.DataContractAttribute; otherwise, an empty collection.
