nats.net
nats.net copied to clipboard
Accept multiple JSON serialization contexts in DI
Proposed change
public NatsBuilder AddJsonSerialization(params JsonSerializerContext[] contexts)
=> ConfigureOptions(opts =>
{
var jsonRegistry = new NatsJsonContextSerializerRegistry(contexts);
return opts with { SerializerRegistry = jsonRegistry };
});
...or collect them to add them in the end during build:
public NatsBuilder AddJsonSerialization(params JsonSerializerContext[] contexts)
=> _contexts.AddRange(contexts);
cc @rickdotnet
I rushed this original implementation and missed that NatsJsonContextSerializerRegistry took in params.
If I pick this up, I'll probably opt for the first option unless someone has opinions against it.
@mtmk , should we wait to see where https://github.com/nats-io/nats.net.v2/pull/530 goes? Or do you think it's worth getting this in sooner?
@mtmk , should we wait to see where #530 goes? Or do you think it's worth getting this in sooner?
@rickdotnet yes good idea. There might be multiple issues and PRs. I might also create a project or milestone for these as well once we have consensus.
since we'll be deprecating this with #689 I shall close this
Fine by me.