-
Notifications
You must be signed in to change notification settings - Fork 1
Support for persistence to EventStoreDB. Fixes #3 #4
Conversation
…tion working. Upgrading to .NET 5.0 should fix this as it supports working with classes without default constructors dotnet/runtime#29895
public static EventData ToEventData(this IEventSerializer @eventSerializer, object @event, string eventName) | ||
{ | ||
var eventPersistenceData = eventSerializer.GetPersistenceData(@event, eventName); | ||
return new EventData(eventPersistenceData.EventId, eventPersistenceData.EventName, eventPersistenceData.IsJsonBytes, eventPersistenceData.EventData, eventPersistenceData.EventMetadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dude wrap this 😛
…on fixes that allow JSON to be deserialized into classes without default constructors
… in the first instance and centralise the logic for mapping event names to types and vice versa
{ | ||
_routes = ImmutableDictionary.CreateRange(routes); | ||
EventNameMappings = eventNameMappings; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename the interface to IEventNameMap
, and the implementation to EventNameMap
? Then the property here can also be called EventNameMap
. Seems a bit more concise and consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
public async Task<long> SaveEventsAsync<TEvent>(string streamName, long expectedStreamVersion, IEnumerable<TEvent> events) | ||
{ | ||
var eventDatas = events.Select(e => _serializer.ToEventData(e)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have an issue to address this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #8
} | ||
|
||
private static string DetermineEventNameForClrType(Type clrType) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this comment be part of a proper documentation comment somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll set up a proper wiki site where we can document usage properly.
No description provided.