public IAggregateRoot Rebuild(IAggregateRoot root, Type type, Guid id, int version = 0) { if (root != null) { version = root.Version; } var evs = _eventStore.GetAggregateRootEvents(id, type.Name, version).OrderBy(a => a.Version).ToList(); if (evs == null || !evs.Any()) { return(root); } if (root == null) { root = Activator.CreateInstance(type, true) as IAggregateRoot; } evs.ForEach(e => root.ReplayEvent(e)); return(root); }
private void HandleInvoke <TEvent>(IAggregateRoot root, IEvent evt) where TEvent : class, IEvent { root.ReplayEvent <TEvent>(evt as TEvent); }