コード例 #1
0
ファイル: ReadOnlyEventStore.cs プロジェクト: mano-cz/BTDB
 bool Process(BlockType blockType, ByteBuffer block, IEventStoreObserver observer)
 {
     if (blockType.HasFlag(BlockType.Compressed))
     {
         CompressionStrategy.Decompress(ref block);
     }
     var reader = new ByteBufferReader(block);
     if (blockType.HasFlag(BlockType.HasTypeDeclaration))
     {
         Mapping.LoadTypeDescriptors(reader);
     }
     var metadata = blockType.HasFlag(BlockType.HasMetadata) ? Mapping.LoadObject(reader) : null;
     uint eventCount;
     if (blockType.HasFlag(BlockType.HasOneEvent))
     {
         eventCount = 1;
     }
     else if (blockType.HasFlag(BlockType.HasMoreEvents))
     {
         eventCount = reader.ReadVUInt32();
     }
     else
     {
         eventCount = 0;
     }
     var readEvents = observer.ObservedMetadata(metadata, eventCount);
     if (!readEvents) return observer.ShouldStopReadingNextEvents();
     var events = new object[eventCount];
     for (var i = 0; i < eventCount; i++)
     {
         events[i] = Mapping.LoadObject(reader);
     }
     observer.ObservedEvents(events);
     return observer.ShouldStopReadingNextEvents();
 }