Table of Contents

Class JsonMessageDeserializer<TMessage>

Namespace
Silverback.Messaging.Serialization
Assembly
Silverback.Integration.dll

Deserializes the JSON messages into an instance of TMessage.

public sealed class JsonMessageDeserializer<TMessage> : IMessageDeserializer, IEquatable<JsonMessageDeserializer<TMessage>>

Type Parameters

TMessage

The type of the messages to be deserialized.

Inheritance
JsonMessageDeserializer<TMessage>
Implements
Inherited Members

Constructors

JsonMessageDeserializer(JsonSerializerOptions?, JsonMessageDeserializerTypeHeaderBehavior?)

Initializes a new instance of the JsonMessageDeserializer<TMessage> class.

public JsonMessageDeserializer(JsonSerializerOptions? options = null, JsonMessageDeserializerTypeHeaderBehavior? typeHeaderBehavior = null)

Parameters

options JsonSerializerOptions

The JsonSerializer options.

typeHeaderBehavior JsonMessageDeserializerTypeHeaderBehavior?

The behavior to adopt when deserializing according to the message type header.

Properties

Options

Gets the JsonSerializer options.

public JsonSerializerOptions? Options { get; }

Property Value

JsonSerializerOptions

RequireHeaders

Gets a value indicating whether this serializer (with the current configuration) needs the headers support to work properly.

public bool RequireHeaders { get; }

Property Value

bool

TypeHeaderBehavior

Gets the behavior to adopt when deserializing according to the message type header.

public JsonMessageDeserializerTypeHeaderBehavior TypeHeaderBehavior { get; }

Property Value

JsonMessageDeserializerTypeHeaderBehavior

Methods

DeserializeAsync(Stream?, MessageHeaderCollection, ConsumerEndpoint)

Deserializes the byte array into a message object.

public ValueTask<DeserializedMessage> DeserializeAsync(Stream? messageStream, MessageHeaderCollection headers, ConsumerEndpoint endpoint)

Parameters

messageStream Stream

The Stream containing the message to be deserialized.

headers MessageHeaderCollection

The message headers collection.

endpoint ConsumerEndpoint

The endpoint.

Returns

ValueTask<DeserializedMessage>

A ValueTask<TResult> representing the asynchronous operation. The task result contains the deserialized message (or null when the input is null or empty) and the type of the message.

Equals(JsonMessageDeserializer<TMessage>?)

public bool Equals(JsonMessageDeserializer<TMessage>? other)

Parameters

other JsonMessageDeserializer<TMessage>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetCompatibleSerializer()

Gets a new IMessageSerializer compatible with this deserializer.

public IMessageSerializer GetCompatibleSerializer()

Returns

IMessageSerializer

A new instance of an IMessageSerializer compatible with this deserializer.

GetHashCode()

public override int GetHashCode()

Returns

int