Table of Contents

Class JsonMessageSerializer

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

Serializes the messages as JSON.

public sealed class JsonMessageSerializer : IMessageSerializer, IEquatable<JsonMessageSerializer>
Inheritance
JsonMessageSerializer
Implements
Inherited Members

Constructors

JsonMessageSerializer(JsonSerializerOptions?, bool?)

Initializes a new instance of the JsonMessageSerializer class.

public JsonMessageSerializer(JsonSerializerOptions? options = null, bool? mustSetTypeHeader = null)

Parameters

options JsonSerializerOptions

The JsonSerializer options.

mustSetTypeHeader bool?

A value indicating whether the message type header (see MessageType) must be set.

Properties

MustSetTypeHeader

Gets a value indicating whether the message type header (see MessageType) must be set. This is necessary when sending multiple message type through the same endpoint, to allow Silverback to automatically figure out the correct type to deserialize into.

public bool MustSetTypeHeader { get; }

Property Value

bool

Options

Gets the JsonSerializer options.

public JsonSerializerOptions? Options { get; }

Property Value

JsonSerializerOptions

Methods

Equals(JsonMessageSerializer?)

public bool Equals(JsonMessageSerializer? other)

Parameters

other JsonMessageSerializer

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

SerializeAsync(object?, MessageHeaderCollection, ProducerEndpoint)

Serializes the specified message object into a byte array.

public ValueTask<Stream?> SerializeAsync(object? message, MessageHeaderCollection headers, ProducerEndpoint endpoint)

Parameters

message object

The message object to be serialized.

headers MessageHeaderCollection

The message headers collection.

endpoint ProducerEndpoint

The endpoint.

Returns

ValueTask<Stream>

A Task<TResult> representing the asynchronous operation. The task result contains the Stream with the serialized message.