Class NewtonsoftJsonMessageDeserializer<TMessage>
Deserializes the JSON messages into an instance of TMessage.
Inherited Members
Namespace: Silverback.Messaging.Serialization
Assembly: Silverback.Integration.Newtonsoft.dll
Syntax
public sealed class NewtonsoftJsonMessageDeserializer<TMessage> : IMessageDeserializer, IEquatable<NewtonsoftJsonMessageDeserializer<TMessage>>
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages to be deserialized. |
Constructors
NewtonsoftJsonMessageDeserializer(JsonSerializerSettings?, MessageEncoding?, JsonMessageDeserializerTypeHeaderBehavior?)
Initializes a new instance of the NewtonsoftJsonMessageDeserializer<TMessage> class.
Declaration
public NewtonsoftJsonMessageDeserializer(JsonSerializerSettings? settings = null, MessageEncoding? encoding = null, JsonMessageDeserializerTypeHeaderBehavior? typeHeaderBehavior = null)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializerSettings | settings | The Newtonsoft.Json.JsonSerializer settings. |
| MessageEncoding? | encoding | The message encoding. The default is UTF8. |
| JsonMessageDeserializerTypeHeaderBehavior? | typeHeaderBehavior | The behavior to adopt when deserializing according to the message type header. |
Properties
Encoding
Gets the message encoding. The default is UTF8.
Declaration
public MessageEncoding Encoding { get; }
Property Value
| Type | Description |
|---|---|
| MessageEncoding |
RequireHeaders
Gets a value indicating whether this serializer (with the current configuration) needs the headers support to work properly.
Declaration
public bool RequireHeaders { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Settings
Gets the Newtonsoft.Json.JsonSerializer settings.
Declaration
public JsonSerializerSettings? Settings { get; }
Property Value
| Type | Description |
|---|---|
| JsonSerializerSettings |
TypeHeaderBehavior
Gets the behavior to adopt when deserializing according to the message type header.
Declaration
public JsonMessageDeserializerTypeHeaderBehavior TypeHeaderBehavior { get; }
Property Value
| Type | Description |
|---|---|
| JsonMessageDeserializerTypeHeaderBehavior |
Methods
DeserializeAsync(Stream?, MessageHeaderCollection, ConsumerEndpoint)
Deserializes the byte array into a message object.
Declaration
public ValueTask<DeserializedMessage> DeserializeAsync(Stream? messageStream, MessageHeaderCollection headers, ConsumerEndpoint endpoint)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | messageStream | The Stream containing the message to be deserialized. |
| MessageHeaderCollection | headers | The message headers collection. |
| ConsumerEndpoint | endpoint | The endpoint. |
Returns
| Type | Description |
|---|---|
| ValueTask<DeserializedMessage> | A ValueTask<TResult> representing the asynchronous operation. The task result contains the
deserialized message (or |
Equals(NewtonsoftJsonMessageDeserializer<TMessage>?)
Deserializes the JSON messages into an instance of TMessage.
Declaration
public bool Equals(NewtonsoftJsonMessageDeserializer<TMessage>? other)
Parameters
| Type | Name | Description |
|---|---|---|
| NewtonsoftJsonMessageDeserializer<TMessage> | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object?)
Deserializes the JSON messages into an instance of TMessage.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
GetCompatibleSerializer()
Gets a new IMessageSerializer compatible with this deserializer.
Declaration
public IMessageSerializer GetCompatibleSerializer()
Returns
| Type | Description |
|---|---|
| IMessageSerializer | A new instance of an IMessageSerializer compatible with this deserializer. |
GetHashCode()
Deserializes the JSON messages into an instance of TMessage.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |