private void AppendEvents(NewStreamEvent[] newEvents)
        {
            long checkPoint     = _inMemoryAllStream.Last.Value.Checkpoint;
            int  streamRevision = _events.LastOrDefault()?.StreamVersion ?? -1;

            foreach (var newStreamEvent in newEvents)
            {
                checkPoint++;
                streamRevision++;

                var inMemoryStreamEvent = new InMemoryStreamEvent(
                    _streamId,
                    newStreamEvent.EventId,
                    streamRevision,
                    checkPoint,
                    _getUtcNow(),
                    newStreamEvent.Type,
                    newStreamEvent.JsonData,
                    newStreamEvent.JsonMetadata);

                _inMemoryAllStream.AddAfter(_inMemoryAllStream.Last, inMemoryStreamEvent);
                _events.Add(inMemoryStreamEvent);
                _eventIds.Add(newStreamEvent.EventId);

                _onStreamAppended();
            }
        }
Esempio n. 2
0
        private void AppendEvents(NewStreamMessage[] newMessages)
        {
            foreach (var newmessage in newMessages)
            {
                var position = _getNextPosition();
                CurrentVersion++;

                var inMemorymessage = new InMemoryStreamMessage(
                    _streamId,
                    newmessage.MessageId,
                    CurrentVersion,
                    position,
                    _getUtcNow(),
                    newmessage.Type,
                    newmessage.JsonData,
                    newmessage.JsonMetadata);

                _messages.Add(inMemorymessage);
                _messagesById.Add(newmessage.MessageId, inMemorymessage);
                _inMemoryAllStream.AddAfter(_inMemoryAllStream.Last, inMemorymessage);
            }
            _onStreamAppended();
        }