Table of Contents

Class NewtonsoftJsonMessageSerializer

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

Serializes the messages as JSON.

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

Constructors

NewtonsoftJsonMessageSerializer(JsonSerializerSettings?, MessageEncoding?, bool?)

Initializes a new instance of the NewtonsoftJsonMessageSerializer class.

public NewtonsoftJsonMessageSerializer(JsonSerializerSettings? settings = null, MessageEncoding? encoding = null, bool? mustSetTypeHeader = null)

Parameters

settings JsonSerializerSettings

The Newtonsoft.Json.JsonSerializer settings.

encoding MessageEncoding?

The message encoding. The default is UTF8.

mustSetTypeHeader bool?

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

Properties

Encoding

Gets the message encoding. The default is UTF8.

public MessageEncoding Encoding { get; }

Property Value

MessageEncoding

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

Settings

Gets the Newtonsoft.Json.JsonSerializer settings.

public JsonSerializerSettings? Settings { get; }

Property Value

JsonSerializerSettings

Methods

Equals(NewtonsoftJsonMessageSerializer?)

public bool Equals(NewtonsoftJsonMessageSerializer? other)

Parameters

other NewtonsoftJsonMessageSerializer

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.