public Event(AggregateRootEvent aggregateRootEvent) { Id = Guid.NewGuid().ToString(); EventType = aggregateRootEvent.GetType().ToString(); EventData = aggregateRootEvent.ToJson(); CreateTime = DateTime.Now; }
public void Replace(params AggregateRootEvent[] events) { AssertNoPriorModificationsHaveBeenMade(); Contract.Assert(Event.GetType() != typeof(EndOfAggregateHistoryEventPlaceHolder), "You cannot call replace on the event that signifies the end of the stream"); _replacementEvents = events; _replacementEvents.ForEach( (e, index) => { e.ManualVersion = e.AggregateRootVersion = Event.AggregateRootVersion + index; e.Replaces = Event.InsertionOrder; e.AggregateRootId = Event.AggregateRootId; e.UtcTimeStamp = Event.UtcTimeStamp; }); CurrentNode = CurrentNode.Replace(_replacementEvents).First(); _eventsAddedCallback.Invoke(_replacementEvents); }