Beispiel #1
0
        public void Write <T>(string streamName, int streamVersion, EntryBatch batch)
        {
            lock (((ICollection)store).SyncRoot)
            {
                if (!TryCanWrite(streamName, streamVersion, out var currentVersion))
                {
                    throw new IndexOutOfRangeException($"Cannot write to stream '{streamName}' with expected version {streamVersion} because the current version is {currentVersion}");
                }

                var offset = 1;
                foreach (var entry in batch.Entries)
                {
                    store.Add(new EntryValue(StreamNameBuilder.BuildStreamNameFor <T>(streamName), streamVersion + offset, entry.Type, entry.Body, entry.Snapshot));
                    offset++;
                }
            }
        }
Beispiel #2
0
 public EntryStream StreamFor <T>(string streamName) => journal.ReadStream(StreamNameBuilder.BuildStreamNameFor <T>(streamName));