public static EventData ToEventData(IEvent e) => new EventData { EventId = e.EventId(), EventName = e.GetType().Name, Data = JsonSerializer.Serialize <object>(e) };
public static EventData ToJson(this IEvent e) => new EventData(e.EventId(), JsonConvert.SerializeObject(e, new JsonSerializerSettings { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.None }), JsonConvert.SerializeObject(e.Meta, new JsonSerializerSettings { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.None }));
public static T Issue <T>(IEvent @event, Func <T> f) where T : ICommand { var cmd = f(); if (cmd != null) { //cmd.CommandId = $"{@event.EventId()}-{cmd.GetType()}-{commandIndex}"; cmd.CorrelationId = @event.GetCorrelation(); cmd.CausationId = @event.EventId(); } return(cmd); }
public static void AddMetaData(this IDictionary <string, string> meta, string streamName, IEvent trigger, long occuredAt = default(long)) => meta.AddMetaData(new EventMetaData ( AggregateName: "unknown", CorrelationId: trigger.GetCorrelation(), CausationId: trigger.EventId(), EventId: Guid.NewGuid(), OccuredAt: occuredAt == default(long) ? DateTime.UtcNow.Ticks : occuredAt, StreamName: streamName, TriggeredBy: trigger.GetType().Name, BasedOnStreamVersion: 0 ));
public static EventData MapObject(this IEvent e) => new EventData(e.EventId(), e, e.Meta);