Class JsonMessageDeserializerBuilder
- Namespace
- Silverback.Messaging.Configuration
- Assembly
- Silverback.Integration.dll
Builds the JsonMessageDeserializer<TMessage>.
public sealed class JsonMessageDeserializerBuilder
- Inheritance
-
JsonMessageDeserializerBuilder
- Inherited Members
Constructors
JsonMessageDeserializerBuilder()
public JsonMessageDeserializerBuilder()
Methods
Build()
Builds the IMessageDeserializer instance.
public IMessageDeserializer Build()
Returns
Configure(Action<JsonSerializerOptions>)
Configures the JsonSerializerOptions. The action is applied to a copy of the options set by the previous calls to Configure(Action<JsonSerializerOptions>) or UseJsonSerializerContext(JsonSerializerContext), if any.
public JsonMessageDeserializerBuilder Configure(Action<JsonSerializerOptions> configureAction)
Parameters
configureActionAction<JsonSerializerOptions>An Action<T> that takes the JsonSerializerOptions and configures it.
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
IgnoreMessageTypeHeader()
Specifies that the message type header must be ignored. The message will always be deserialized into the predefined model.
public JsonMessageDeserializerBuilder IgnoreMessageTypeHeader()
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
UseJsonSerializerContext(JsonSerializerContext)
Specifies the source-generated JsonSerializerContext to be used. The deserializer will use the context's own Options, replacing the options set by the previous calls to Configure(Action<JsonSerializerOptions>). Call Configure(Action<JsonSerializerOptions>) afterwards to further customize a copy of these options, for example to add more contexts to the TypeInfoResolverChain. The additional contexts will use these same options.
public JsonMessageDeserializerBuilder UseJsonSerializerContext(JsonSerializerContext context)
Parameters
contextJsonSerializerContextThe JsonSerializerContext. Pass the generated
Defaultinstance to use the options declared via the JsonSourceGenerationOptionsAttribute.
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
UseModel(Type)
Specifies the message type. The deserialization will work regardless of the message type header (ideal for interoperability) and by default the message type header will be omitted by the producer (unless a subtype is being produced is called).
public JsonMessageDeserializerBuilder UseModel(Type messageType)
Parameters
messageTypeTypeThe type of the message to serialize or deserialize.
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
UseModel<TMessage>()
Specifies the message type. The deserialization will work regardless of the message type header (ideal for interoperability) and by default the message type header will be omitted by the producer (unless a subtype is being produced is called).
public JsonMessageDeserializerBuilder UseModel<TMessage>()
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
Type Parameters
TMessageThe type of the message to serialize or deserialize.
WithMandatoryMessageTypeHeader()
Specifies that an exception must be thrown if the consumed message doesn't specify the message type header.
public JsonMessageDeserializerBuilder WithMandatoryMessageTypeHeader()
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.
WithOptionalMessageTypeHeader()
Specifies that the message type header must be used when sent with the consumed message, otherwise the predefined model has to be used.
public JsonMessageDeserializerBuilder WithOptionalMessageTypeHeader()
Returns
- JsonMessageDeserializerBuilder
The JsonMessageDeserializerBuilder so that additional calls can be chained.