Exemplo n.º 1
0
        protected void RaiseEvent <TEvent>(TEvent @event)
            where TEvent : DomainEventBase
        {
            DomainEventBase eventWithAggregate = @event.WithAggregate(Id, _version);

            ApplyEvent(eventWithAggregate, _version + 1);
            _domainEvents.Add(eventWithAggregate);
        }
Exemplo n.º 2
0
        protected void ApplyEvent(DomainEventBase @event, long version)
        {
            if (!_domainEvents.Any(x => Equals(x.EventId, @event.EventId)))
            {
                _eventHandlers[@event.GetType()](@event);

                _version = version;
            }
        }