There is a property off of _store.Conventions that allows users to customize the way RavenDb serializes. This is of particular use to me because I use NServicebus which handles events as interfaces which Json.NET can't deserialize properly (always a dynamic type).
I have to hook into Json.NET's contract resolver to message map the event back to its interface definition so aggregate Handle methods can process it correctly.
This patch adds a SerializerCustomizations property to RavenPersistenceOptions which is an Action<JsonSerializer> - exactly the same thing _store.Conventions.CustomizeJsonSerializer accepts.
Which allows me to inject custom binders and contract resolvers into ravendb like so:
public static RavenPersistenceWireup UsingAggregatesRavenPersistence(
this Wireup wireup,
string connectionName)
{
var options = new RavenPersistenceOptions(serializerCustomizations: s =>
{
s.Binder = new EventSerializationBinder();
s.ContractResolver = new EventContractResolver();
});
return wireup.UsingRavenPersistence(connectionName, options);
}
There is a property off of _store.Conventions that allows users to customize the way RavenDb serializes. This is of particular use to me because I use NServicebus which handles events as interfaces which Json.NET can't deserialize properly (always a dynamic type). I have to hook into Json.NET's contract resolver to message map the event back to its interface definition so aggregate Handle methods can process it correctly.
This patch adds a SerializerCustomizations property to RavenPersistenceOptions which is an
Action<JsonSerializer>
- exactly the same thing_store.Conventions.CustomizeJsonSerializer
accepts.Which allows me to inject custom binders and contract resolvers into ravendb like so:
This behavior is much cleaner then what the elliotritchie/NES project does, which is here: https://github.com/elliotritchie/NES/blob/v5/src/NES.NEventStore.Raven/CustomizedRavenSerializerWireup.cs
he actually has to use reflection to pull the IDocumentStore from your object. Figured this was a better solution