Class JsonMessageSerializerBuilder
- Namespace
- Silverback.Messaging.Configuration
- Assembly
- Silverback.Integration.dll
Builds the JsonMessageSerializer.
public sealed class JsonMessageSerializerBuilder
- Inheritance
-
JsonMessageSerializerBuilder
- Inherited Members
Constructors
JsonMessageSerializerBuilder()
public JsonMessageSerializerBuilder()
Methods
Build()
Builds the IMessageSerializer instance.
public IMessageSerializer 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 JsonMessageSerializerBuilder Configure(Action<JsonSerializerOptions> configureAction)
Parameters
configureActionAction<JsonSerializerOptions>An Action<T> that takes the JsonSerializerOptions and configures it.
Returns
- JsonMessageSerializerBuilder
The JsonMessageSerializerBuilder so that additional calls can be chained.
DisableTypeHeader()
Specifies that the message type header (see MessageType) must not be set.
public JsonMessageSerializerBuilder DisableTypeHeader()
Returns
- JsonMessageSerializerBuilder
The JsonMessageSerializerBuilder so that additional calls can be chained.
SetTypeHeader()
Specifies that 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 JsonMessageSerializerBuilder SetTypeHeader()
Returns
- JsonMessageSerializerBuilder
The JsonMessageSerializerBuilder so that additional calls can be chained.
UseJsonSerializerContext(JsonSerializerContext)
Specifies the source-generated JsonSerializerContext to be used. The serializer 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 JsonMessageSerializerBuilder UseJsonSerializerContext(JsonSerializerContext context)
Parameters
contextJsonSerializerContextThe JsonSerializerContext. Pass the generated
Defaultinstance to use the options declared via the JsonSourceGenerationOptionsAttribute.
Returns
- JsonMessageSerializerBuilder
The JsonMessageSerializerBuilder so that additional calls can be chained.