Class NewtonsoftJsonMessageDeserializer<TMessage>
- Namespace
- Silverback.Messaging.Serialization
- Assembly
- Silverback.Integration.Newtonsoft.dll
Deserializes the JSON messages into an instance of TMessage.
public sealed class NewtonsoftJsonMessageDeserializer<TMessage> : IMessageDeserializer, IEquatable<NewtonsoftJsonMessageDeserializer<TMessage>>
Type Parameters
TMessageThe type of the messages to be deserialized.
- Inheritance
-
NewtonsoftJsonMessageDeserializer<TMessage>
- Implements
-
IEquatable<NewtonsoftJsonMessageDeserializer<TMessage>>
- Inherited Members
Constructors
NewtonsoftJsonMessageDeserializer(JsonSerializerSettings?, MessageEncoding?, JsonMessageDeserializerTypeHeaderBehavior?)
Initializes a new instance of the NewtonsoftJsonMessageDeserializer<TMessage> class.
public NewtonsoftJsonMessageDeserializer(JsonSerializerSettings? settings = null, MessageEncoding? encoding = null, JsonMessageDeserializerTypeHeaderBehavior? typeHeaderBehavior = null)
Parameters
settingsJsonSerializerSettingsThe Newtonsoft.Json.JsonSerializer settings.
encodingMessageEncoding?The message encoding. The default is UTF8.
typeHeaderBehaviorJsonMessageDeserializerTypeHeaderBehavior?The behavior to adopt when deserializing according to the message type header.
Properties
Encoding
Gets the message encoding. The default is UTF8.
public MessageEncoding Encoding { get; }
Property Value
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
Settings
Gets the Newtonsoft.Json.JsonSerializer settings.
public JsonSerializerSettings? Settings { get; }
Property Value
- JsonSerializerSettings
TypeHeaderBehavior
Gets the behavior to adopt when deserializing according to the message type header.
public JsonMessageDeserializerTypeHeaderBehavior TypeHeaderBehavior { get; }
Property Value
Methods
DeserializeAsync(Stream?, MessageHeaderCollection, ConsumerEndpoint)
Deserializes the byte array into a message object.
public ValueTask<DeserializedMessage> DeserializeAsync(Stream? messageStream, MessageHeaderCollection headers, ConsumerEndpoint endpoint)
Parameters
messageStreamStreamThe Stream containing the message to be deserialized.
headersMessageHeaderCollectionThe message headers collection.
endpointConsumerEndpointThe endpoint.
Returns
- ValueTask<DeserializedMessage>
A ValueTask<TResult> representing the asynchronous operation. The task result contains the deserialized message (or
nullwhen the input is null or empty) and the type of the message.
Equals(NewtonsoftJsonMessageDeserializer<TMessage>?)
public bool Equals(NewtonsoftJsonMessageDeserializer<TMessage>? other)
Parameters
otherNewtonsoftJsonMessageDeserializer<TMessage>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
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()