Class XmlContentDeserializer
- Namespace
- Kampute.HttpClient.DataContract
- Assembly
- Kampute.HttpClient.DataContract.dll
Provides functionality for deserializing XML content from HTTP responses into objects.
public sealed class XmlContentDeserializer : HttpContentDeserializer, IHttpContentDeserializer
- Inheritance
-
XmlContentDeserializer
- Implements
- Inherited Members
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
mediaTypestringThe media type of the content.
modelTypeTypeThe target model type for deserialization.
Returns
- bool
true if the deserializer supports the media type and the model type is not null and is marked with a DataContractAttribute; otherwise, false.
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
contentHttpContentThe HttpContent to read from.
modelTypeTypeThe type of the object to read.
cancellationTokenCancellationTokenA 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
contentormodelTypeis null.
GetSupportedMediaTypes(Type)
Retrieves a collection of supported media types for a specific model type.
public override IEnumerable<string> GetSupportedMediaTypes(Type modelType)
Parameters
modelTypeTypeThe 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 null and is marked with a DataContractAttribute; otherwise, an empty collection.