public async Task <ReadModel <TState> > ReadFrom(TId id)
        {
            var streamData = await reader.ReadFrom(new ReadStreamBackwardsStrategy(id.ToString()));

            var rehydratedState = configs.StateRehydrator.RehydrateFrom <TState>(streamData.results.Select(x => x.Event));

            return(new ReadModel <TState>(rehydratedState, streamData.streamVersion));
        }
        public async Task <ReadModel <TState> > ReadFrom(TId id)
        {
            var streamData = await reader.ReadFrom(id.ToString());

            var events = await streamData.events.Reverse().Select(x => x.ToItemWithType()).ToArrayAsync();

            var rehydratedState = configs.StateRehydrator.RehydrateFrom <TState>(events);

            //TODO: REPLACE WHEN BO CHANGES TO LONG!!
            return(new ReadModel <TState>(rehydratedState, (int)streamData.streamPosition.ToInt64()));
        }
Ejemplo n.º 3
0
        public async Task <bool> Contains(TId selector)
        {
            try
            {
                var readResult = await eventReader.ReadFrom(selector.ToString());

                return(readResult.streamExists && await readResult.events.AnyAsync());
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public async Task <ReadModel <TState> > ReadFrom(TId id)
        {
            var streamData = await reader.ReadFrom(id.ToString());

            var rehydratedState = configs.StateRehydrator.RehydrateFrom <TState>(streamData.events);

            return(new ReadModel <TState>(rehydratedState, streamData.streamVersion));
        }
        public async Task Initialize()
        {
            CheckDisposedState();
            //TODO: user credentials
            var streamData = await eventReader.ReadFrom(streamName);

            LoadFromEvents(streamData.events.ToArray(), streamData.streamVersion);
        }
Ejemplo n.º 6
0
        public async Task Initialize(DateTime?appliesAt = null)
        {
            CheckDisposedState();
            //TODO: user credentials
            var streamData = await eventReader.ReadFrom(new ReadStreamBackwardsStrategy(streamName), appliesAt);

            LoadFromEvents(streamData.results.Select(x => x.Event).ToArray(), streamData.streamVersion);
        }
        public async Task Initialize(Func <IAmAStoredEvent, bool> loadEventPredicate = null)
        {
            CheckDisposedState();
            //TODO: user credentials
            var data = await eventReader.ReadFrom(streamName, loadEventPredicate);

            streamExists = data.streamExists;

            var events = await data.events.Reverse().ToArrayAsync();

            LoadFromEvents(events.Select(x => x.ToItemWithType()).ToArray(), data.streamPosition.ToInt64());
        }