Пример #1
0
        public override void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources,
                                                                     Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object)
        {
            var sourcesForEntries   = sources.ToList();
            var entries             = _entryAdapterProvider.AsEntries <TSource, IEntry <T> >(sourcesForEntries, fromStreamVersion, metadata);
            var dispatchableEntries = entries.ToList();

            Insert(streamName, fromStreamVersion, dispatchableEntries);
            IState?raw;
            Optional <TSnapshotState> snapshotResult;

            if (snapshot != null)
            {
                raw = _stateAdapterProvider.AsRaw <TSnapshotState, IState>(streamName, snapshot, fromStreamVersion);
                _snapshots.Add(streamName, raw);
                snapshotResult = Optional.Of(snapshot);
            }
            else
            {
                raw            = null;
                snapshotResult = Optional.Empty <TSnapshotState>();
            }

            Dispatch(streamName, fromStreamVersion, dispatchableEntries, raw);
            interest.AppendAllResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, fromStreamVersion, sourcesForEntries, snapshotResult, @object);
        }
Пример #2
0
        public override void AppendAll <TSource>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources, Metadata metadata, IAppendResultInterest interest, object @object)
        {
            var sourcesForEntries   = sources.ToList();
            var entries             = _entryAdapterProvider.AsEntries <TSource, IEntry <T> >(sourcesForEntries, fromStreamVersion, metadata);
            var dispatchableEntries = entries.ToList();

            Insert(streamName, fromStreamVersion, dispatchableEntries);

            Dispatch(streamName, fromStreamVersion, dispatchableEntries, null);
            interest.AppendAllResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, fromStreamVersion, sourcesForEntries, Optional.Empty <object>(), @object);
        }