Beispiel #1
0
        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();
        }
Beispiel #2
0
 private bool AlreadyTracked(IAggregateRoot aggregateRoot)
 {
     return(_trackedAggregates.Any(q => q.GetType() == aggregateRoot.GetType() && q.GetId().Equals(aggregateRoot.GetId())));
 }
Beispiel #3
0
 public static string ResolveForSnapshot(IAggregateRoot aggregate)
 {
     return($"EventSourceStructure-{aggregate.GetType().Name}-snapshot-{aggregate.GetId()}");
 }
Beispiel #4
0
 public static string Generate(IAggregateRoot aggregate)
 {
     return($"EventSourceStructure-{aggregate.GetType().Name}-{aggregate.GetId()}");
 }