public void Save(IAggregateRoot aggregate) { List <IEvent> aggregateEvents; if (!aggregateEventDictionary.TryGetValue(aggregate.GetId(), out aggregateEvents)) { aggregateEvents = new List <IEvent>(); aggregateEventDictionary.Add(aggregate.GetId(), aggregateEvents); } foreach (var @event in aggregate.GetUncommitedChanges()) { aggregateEvents.Add(@event); this.eventPublisher.Publish(@event); } aggregate.MarkChangesAsCommited(); }
private bool AlreadyTracked(IAggregateRoot aggregateRoot) { return(_trackedAggregates.Any(q => q.GetType() == aggregateRoot.GetType() && q.GetId().Equals(aggregateRoot.GetId()))); }
public static string ResolveForSnapshot(IAggregateRoot aggregate) { return($"EventSourceStructure-{aggregate.GetType().Name}-snapshot-{aggregate.GetId()}"); }
public static string Generate(IAggregateRoot aggregate) { return($"EventSourceStructure-{aggregate.GetType().Name}-{aggregate.GetId()}"); }