Пример #1
0
        public async Task <KeyValuePair <int, TState> > ReadStateFromStorage()
        {
            var state          = State ?? new TState();
            var version        = Version;
            var eventsToReplay = await _events.ReadAsync(EventStreams);

            if (eventsToReplay != null && eventsToReplay.Any())
            {
                version = eventsToReplay.Count();
                state.Replay(eventsToReplay.Select(e => e.Args));
            }

            return(new KeyValuePair <int, TState>(version, state));
        }
Пример #2
0
        public async Task <KeyValuePair <int, TState> > ReadStateFromStorage()
        {
            var state   = State ?? new TState();
            var version = Version;
            var events  = await _events.ReadAsync(IdentityString, version + 1);

            if (events != null && events.Any())
            {
                version = events.Max(e => e.Version);
                state.Replay(events.Select(e => e.Args));
            }

            return(new KeyValuePair <int, TState>(version, state));
        }