Skip to content
Documentation

ISerializer Interface

General interface representing an object that can be used to serialize/deserialize an object to a stream.

public interface ISerializer

Derived
↳ ISerializer<TData>
↳ Serializer<TData,TParameters>
↳ XmlSerializer<TData>

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; }

System.Net.Http.Headers.MediaTypeHeaderValue

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; }

System.Net.Http.Headers.MediaTypeHeaderValue

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);

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));

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.

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));

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.

System.Threading.Tasks.Task
Returns a System.Threading.Tasks.Task that completes once all of data has been written to outputStream.

© 2026 Volue.Version v0.6.38017 November 2026