Exemplo n.º 1
0
        private void LoadStream(Aggregate aggregate, IList <ICommitedEvent> commitedEvents)
        {
            if (commitedEvents.Count > 0)
            {
                var events = commitedEvents.Select(_eventSerializer.Deserialize);

                if (_eventUpdateManager != null)
                {
                    _logger.LogDebug("Calling Update Manager");

                    events = _eventUpdateManager.Update(events);
                }

                aggregate.LoadFromHistory(new CommitedDomainEventCollection(events));
                aggregate.SetVersion(commitedEvents.Select(e => e.Version).Max());
            }
        }
Exemplo n.º 2
0
        private void LoadAggregate <TAggregate>(TAggregate aggregate, IEnumerable <ICommittedEvent> committedEvents) where TAggregate : Aggregate
        {
            var flatten = committedEvents as ICommittedEvent[] ?? committedEvents.ToArray();


            if (flatten.Any())
            {
                var events = flatten.Select(e => e.Data).Cast <IDomainEvent>();

                if (_eventUpdateManager != null)
                {
                    _logger.LogDebug("Calling Update Manager");

                    events = _eventUpdateManager.Update(events);
                }

                aggregate.LoadFromHistory(new CommittedEventsCollection(events));

                aggregate.UpdateVersion(flatten.Select(e => e.Version).Max());
            }
        }