Exemple #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);
 }
Exemple #2
0
        protected T RaiseEventInternal <T>(T @event, Action <T> modification) where T : IEvent, new()
        {
            SetEventDefaults(@event);

            modification?.Invoke(@event);

            @event.AssertValidation();
            UnCommittedEvents.Add(@event);

            return(@event);
        }
        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);
        }
Exemple #4
0
 public void RevertChanges()
 {
     UnCommittedEvents.Clear();
 }
Exemple #5
0
 public void CommitChanges(long commitVersion)
 {
     committedEvents.AddRange(UnCommittedEvents);
     UnCommittedEvents.Clear();
     CommitVersion = commitVersion;
 }