public UserAR(Snapshot snapshot, TransitionStream stream) { _state = snapshot != null ? (UserState)snapshot.Payload : new UserState(); foreach (var transition in stream.Read()) { foreach (var @event in transition.Events) { _state.Mutate((IEvent)@event.Data); } } }
public static int GetVersion(this TransitionStream stream) { return(stream.Read().Any() ? stream.Read().Max(x => x.Id.Version) : 0); }