Class NewtonsoftJsonMessageSerializer
Serializes the messages as JSON.
Inherited Members
Namespace: Silverback.Messaging.Serialization
Assembly: Silverback.Integration.Newtonsoft.dll
Syntax
public sealed class NewtonsoftJsonMessageSerializer : IMessageSerializer, IEquatable<NewtonsoftJsonMessageSerializer>
Constructors
NewtonsoftJsonMessageSerializer(JsonSerializerSettings?, MessageEncoding?, bool?)
Initializes a new instance of the NewtonsoftJsonMessageSerializer class.
Declaration
public NewtonsoftJsonMessageSerializer(JsonSerializerSettings? settings = null, MessageEncoding? encoding = null, bool? mustSetTypeHeader = null)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializerSettings | settings | The Newtonsoft.Json.JsonSerializer settings. |
| MessageEncoding? | encoding | The message encoding. The default is UTF8. |
| bool? | mustSetTypeHeader | A value indicating whether the message type header (see MessageType) must be set. |
Properties
Encoding
Gets the message encoding. The default is UTF8.
Declaration
public MessageEncoding Encoding { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public bool MustSetTypeHeader { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Settings
Gets the Newtonsoft.Json.JsonSerializer settings.
Declaration
public JsonSerializerSettings? Settings { get; }
Property Value
| Type | Description |
|---|---|
| JsonSerializerSettings |
Methods
Equals(NewtonsoftJsonMessageSerializer?)
Serializes the messages as JSON.
Declaration
public bool Equals(NewtonsoftJsonMessageSerializer? other)
Parameters
| Type | Name | Description |
|---|---|---|
| NewtonsoftJsonMessageSerializer | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object?)
Serializes the messages as JSON.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
GetHashCode()
Serializes the messages as JSON.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
SerializeAsync(object?, MessageHeaderCollection, ProducerEndpoint)
Serializes the specified message object into a byte array.
Declaration
public ValueTask<Stream?> SerializeAsync(object? message, MessageHeaderCollection headers, ProducerEndpoint endpoint)
Parameters
| Type | Name | Description |
|---|---|---|
| object | message | The message object to be serialized. |
| MessageHeaderCollection | headers | The message headers collection. |
| ProducerEndpoint | endpoint | The endpoint. |
Returns
| Type | Description |
|---|---|
| ValueTask<Stream> | A Task<TResult> representing the asynchronous operation. The task result contains the Stream with the serialized message. |