Пример #1
0
 /// <summary>
 /// Apply a event.
 /// </summary>
 /// <param name="evnt">A domanin evnt.</param>
 public void ApplyEvent(IEvent evnt)
 {
     if (evnt == null)
     {
         throw new ArgumentNullException(nameof(evnt));
     }
     Handler(evnt);
     UnCommittedEvents.Enqueue(evnt);
 }
Пример #2
0
        public virtual void AddEvent(IVersionedEvent versionedEvent)
        {
            if (!AggregateRoot.Active)
            {
                throw new InvalidOperationException("No changes can be made to this aggregate, since it is not active");
            }

            if (!versionedEvent.IsInitialized)
            {
                versionedEvent.Initialize(Key.ToString(), GetType().Name, ++Version,
                                          AggregateRoot.Key.ToString(), AggregateRoot.GetType().Name);
            }

            ApplyUpdate(versionedEvent);
            UnCommittedEvents.Enqueue(versionedEvent);
        }