Exemplo n.º 1
0
        private TAggregateRoot Restore(IEnumerable <Event> events, BaseMemento memento)
        {
            var aggregateRoot = new TAggregateRoot();

            if (memento != null)
            {
                //还原快照
                events = events.Where(@event => @event.Version >= memento.Version);
                aggregateRoot.SetMemento(memento);
            }
            //还原事件
            aggregateRoot.RestoreEvents(events);

            return(aggregateRoot);
        }
Exemplo n.º 2
0
 public abstract void SetMemento(BaseMemento memento);