private void AppendEvents(int numEventsToBeSent, IStreamStoreConnection conn, string streamName, int startNumber = 0) { for (int evtNumber = startNumber; evtNumber < numEventsToBeSent + startNumber; evtNumber++) { var evt = new SubscriptionTestEvent(evtNumber); conn.AppendToStream(streamName, ExpectedVersion.Any, null, _serializer.Serialize(evt)); } }
private void AppendEvents(int numEventsToBeSent, IStreamStoreConnection conn, string streamName) { _toh.WriteLine( $"Appending {numEventsToBeSent} events to stream \"{streamName}\" with connection {conn.ConnectionName}"); for (int evtNumber = 0; evtNumber < numEventsToBeSent; evtNumber++) { var evt = new ReadTestEvent(evtNumber); conn.AppendToStream(streamName, ExpectedVersion.Any, null, _serializer.Serialize(evt)); } }
private void AppendEvents( int numEventsToBeSent, IStreamStoreConnection conn, string streamName, int value) { for (int evtNumber = 0; evtNumber < numEventsToBeSent; evtNumber++) { var evt = new ReadModelTestEvent(evtNumber, value); conn.AppendToStream(streamName, ExpectedVersion.Any, null, Serializer.Serialize(evt)); } }
private void AppendEventArray(int numEventsToBeSent, IStreamStoreConnection conn, string streamName) { _toh.WriteLine( $"Appending {numEventsToBeSent} events to stream \"{streamName}\" with connection {conn.ConnectionName}"); var events = new IMessage[numEventsToBeSent]; for (int evtNumber = 0; evtNumber < numEventsToBeSent; evtNumber++) { events[evtNumber] = new ReadTestEvent(evtNumber); } conn.AppendToStream(streamName, ExpectedVersion.Any, null, events.Select(x => _serializer.Serialize(x)).ToArray()); }
public void Save(IEventSource aggregate) { var commitHeaders = new Dictionary <string, object> { { CommitIdHeader, Guid.NewGuid() /*commitId*/ }, { AggregateClrTypeNameHeader, aggregate.GetType().AssemblyQualifiedName }, { AggregateClrTypeHeader, aggregate.GetType().Name } }; var streamName = _streamNameBuilder.GenerateForAggregate(aggregate.GetType(), aggregate.Id); var newEvents = aggregate.TakeEvents().ToArray(); var expectedVersion = aggregate.ExpectedVersion; var eventsToSave = new EventData[newEvents.Length]; for (int i = 0; i < newEvents.Length; i++) { eventsToSave[i] = _eventSerializer.Serialize( newEvents[i], new Dictionary <string, object>(commitHeaders)); } _streamStoreConnection.AppendToStream(streamName, expectedVersion, null, eventsToSave); }