示例#1
0
        void IEventSourcedAggregate.ApplyChanges(Changeset changeset)
        {
            // skip if same version
            if (changeset.AggregateVersion == this.Version)
            {
                return;
            }

            if (changeset.AggregateVersion != this.Version + 1)
            {
                throw new AggregateRestoreException(this.Version + 1, changeset.AggregateVersion);
            }

            this.Version = changeset.AggregateVersion;
            foreach (var @event in changeset.Events)
            {
                this.Dispatch(@event);
            }
        }
示例#2
0
 void IEventSourcedAggregate.ChangesPersisted(Changeset changeset)
 {
     this.Version = changeset.AggregateVersion;
     this.PendingChanges.Clear();
 }