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
settingsJsonSerializerSettingsThe Newtonsoft.Json.JsonSerializer settings.
encodingMessageEncoding?The message encoding. The default is UTF8.
mustSetTypeHeaderbool?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
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
Settings
Gets the Newtonsoft.Json.JsonSerializer settings.
public JsonSerializerSettings? Settings { get; }
Property Value
- JsonSerializerSettings
Methods
Equals(NewtonsoftJsonMessageSerializer?)
public bool Equals(NewtonsoftJsonMessageSerializer? other)
Parameters
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
SerializeAsync(object?, MessageHeaderCollection, ProducerEndpoint)
Serializes the specified message object into a byte array.
public ValueTask<Stream?> SerializeAsync(object? message, MessageHeaderCollection headers, ProducerEndpoint endpoint)
Parameters
messageobjectThe message object to be serialized.
headersMessageHeaderCollectionThe message headers collection.
endpointProducerEndpointThe endpoint.
Returns
- ValueTask<Stream>
A Task<TResult> representing the asynchronous operation. The task result contains the Stream with the serialized message.