public void Write(string streamName, int streamVersion, EntryBatch batch) { lock (store) { foreach (EntryBatch.Entry entry in batch.Entries) { store.Add(new EntryValue(streamName, streamVersion, entry.Type, entry.Body, entry.Snapshot)); } } }
public void Write(EntryBatch batch) { lock (store) { foreach (EntryBatch.Entry entry in batch.Entries) { store.Add(new EntryValue("", 0, entry.Type, entry.Body, "")); } } }
protected EntryBatch ToBatch <T>(IEnumerable <T> sources) where T : DomainEvent { var localSources = sources.ToList(); var batch = new EntryBatch(localSources.Count); foreach (var source in localSources) { var eventBody = Serialization.Serialize(source); var assemblyQualifiedName = source?.GetType().AssemblyQualifiedName; if (!string.IsNullOrEmpty(assemblyQualifiedName)) { batch.AddEntry(assemblyQualifiedName !, eventBody); } } return(batch); }
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++; } } }
public void Write(EntryBatch batch) { lock (((ICollection)store).SyncRoot) { if (!TryCanWrite(string.Empty, EntryValue.NoStreamVersion, out var currentVersion)) { throw new IndexOutOfRangeException($"Cannot write to stream '{string.Empty}' with expected version {EntryValue.NoStreamVersion} because the current version is {currentVersion}"); } var offset = 1; foreach (var entry in batch.Entries) { store.Add(new EntryValue(string.Empty, 0 + offset, entry.Type, entry.Body, string.Empty)); offset++; } } }