ISerializer Interface
General interface representing an object that can be used to serialize/deserialize an object to a stream.
public interface ISerializerDerived
↳ ISerializer<TData>
↳ Serializer<TData,TParameters>
↳ XmlSerializer<TData>
Properties
Section titled “Properties”ISerializer.OriginalMediaType Property
Section titled “ISerializer.OriginalMediaType Property”The media type this serializer was initially configured with (see the Configure(MediaTypeHeaderValue) method). May include wildcards etc. i.e. “*/*+json”. Must be set by Configure(MediaTypeHeaderValue).
System.Net.Http.Headers.MediaTypeHeaderValue OriginalMediaType { get; }Property Value
Section titled “Property Value”System.Net.Http.Headers.MediaTypeHeaderValue
ISerializer.ParsedMediaType Property
Section titled “ISerializer.ParsedMediaType Property”The actual media type that’s used by the serializer. For example, assuming Configure(MediaTypeHeaderValue) is called with “*/*+json” this serializer may interpret this as “application/hal+json;charset=utf-8;indentation=true”. This property should then contain that final media type used.
System.Net.Http.Headers.MediaTypeHeaderValue ParsedMediaType { get; }Property Value
Section titled “Property Value”System.Net.Http.Headers.MediaTypeHeaderValue
Methods
Section titled “Methods”ISerializer.Configure(MediaTypeHeaderValue) Method
Section titled “ISerializer.Configure(MediaTypeHeaderValue) Method”Configures this instance with a specific media type (i.e. “application/json”, “text/html”, etc.). Implementations must use this method to interpret media type parameters, set default values, etc. This method must also set OriginalMediaType to the value of mediaType and ParsedMediaType to the media type containing no wildcards and any default values for parameters used.
void Configure(System.Net.Http.Headers.MediaTypeHeaderValue mediaType);Parameters
Section titled “Parameters”mediaType System.Net.Http.Headers.MediaTypeHeaderValue
The media type for this serializer to use.
ISerializer.DeserializeAsObject(Stream, CancellationToken) Method
Section titled “ISerializer.DeserializeAsObject(Stream, CancellationToken) Method”Asynchronously deserializes an object from the given inputStream.
System.Threading.Tasks.Task<object?> DeserializeAsObject(System.IO.Stream inputStream, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));Parameters
Section titled “Parameters”inputStream System.IO.Stream
The System.IO.Stream to read data from.
cancellationToken System.Threading.CancellationToken
A System.Threading.CancellationToken to signal the serializer to attempt cancelling the operation.
Returns
Section titled “Returns”System.Threading.Tasks.Task<System.Object>
A System.Threading.Tasks.Task<> that completes when the object has been successfully read from the inputStream.
ISerializer.SerializeObject(object, Stream, CancellationToken) Method
Section titled “ISerializer.SerializeObject(object, Stream, CancellationToken) Method”Asynchronously serializes data into the outputStream.
System.Threading.Tasks.Task SerializeObject(object? data, System.IO.Stream outputStream, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));Parameters
Section titled “Parameters”data System.Object
The object to serialize.
outputStream System.IO.Stream
The stream to serialize to.
cancellationToken System.Threading.CancellationToken
A System.Threading.CancellationToken to signal the serializer to attempt cancelling the operation.
Returns
Section titled “Returns”System.Threading.Tasks.Task
Returns a System.Threading.Tasks.Task that completes once all of data has been written to outputStream.