/** <inheritDoc /> */ public void ReadBinary(IBinaryReader reader) { Byte = reader.ReadByte("Byte"); ByteArray = reader.ReadByteArray("ByteArray"); Char = reader.ReadChar("Char"); CharArray = reader.ReadCharArray("CharArray"); Short = reader.ReadShort("Short"); ShortArray = reader.ReadShortArray("ShortArray"); Int = reader.ReadInt("Int"); IntArray = reader.ReadIntArray("IntArray"); Long = reader.ReadLong("Long"); LongArray = reader.ReadLongArray("LongArray"); Boolean = reader.ReadBoolean("Boolean"); BooleanArray = reader.ReadBooleanArray("BooleanArray"); Float = reader.ReadFloat("Float"); FloatArray = reader.ReadFloatArray("FloatArray"); Double = reader.ReadDouble("Double"); DoubleArray = reader.ReadDoubleArray("DoubleArray"); Decimal = reader.ReadDecimal("Decimal"); DecimalArray = reader.ReadDecimalArray("DecimalArray"); Date = reader.ReadTimestamp("Date"); DateArray = reader.ReadTimestampArray("DateArray"); String = reader.ReadString("String"); StringArray = reader.ReadStringArray("StringArray"); Guid = reader.ReadObject<Guid>("Guid"); GuidArray = reader.ReadGuidArray("GuidArray"); }
/** <inheritDoc /> */ public void ReadBinary(IBinaryReader reader) { Byte = reader.ReadByte("Byte"); ByteArray = reader.ReadByteArray("ByteArray"); Char = reader.ReadChar("Char"); CharArray = reader.ReadCharArray("CharArray"); Short = reader.ReadShort("Short"); ShortArray = reader.ReadShortArray("ShortArray"); Int = reader.ReadInt("Int"); IntArray = reader.ReadIntArray("IntArray"); Long = reader.ReadLong("Long"); LongArray = reader.ReadLongArray("LongArray"); Boolean = reader.ReadBoolean("Boolean"); BooleanArray = reader.ReadBooleanArray("BooleanArray"); Float = reader.ReadFloat("Float"); FloatArray = reader.ReadFloatArray("FloatArray"); Double = reader.ReadDouble("Double"); DoubleArray = reader.ReadDoubleArray("DoubleArray"); Decimal = reader.ReadDecimal("Decimal"); DecimalArray = reader.ReadDecimalArray("DecimalArray"); Date = reader.ReadTimestamp("Date"); DateArray = reader.ReadTimestampArray("DateArray"); String = reader.ReadString("String"); StringArray = reader.ReadStringArray("StringArray"); Guid = reader.ReadObject <Guid>("Guid"); GuidArray = reader.ReadGuidArray("GuidArray"); }
public void ReadBinary(IBinaryReader reader) { Assert.AreEqual(1, reader.ReadByte("Byte")); Assert.AreEqual(new byte[] { 1 }, reader.ReadByteArray("ByteArray")); Assert.AreEqual('1', reader.ReadChar("Char")); Assert.AreEqual(new[] { '1' }, reader.ReadCharArray("CharArray")); Assert.AreEqual(1, reader.ReadShort("Short")); Assert.AreEqual(new short[] { 1 }, reader.ReadShortArray("ShortArray")); Assert.AreEqual(1, reader.ReadInt("Int")); Assert.AreEqual(new[] { 1 }, reader.ReadIntArray("IntArray")); Assert.AreEqual(1, reader.ReadLong("Long")); Assert.AreEqual(new long[] { 1 }, reader.ReadLongArray("LongArray")); Assert.AreEqual(true, reader.ReadBoolean("Boolean")); Assert.AreEqual(new[] { true }, reader.ReadBooleanArray("BooleanArray")); Assert.AreEqual(1, reader.ReadFloat("Float")); Assert.AreEqual(new float[] { 1 }, reader.ReadFloatArray("FloatArray")); Assert.AreEqual(1, reader.ReadDouble("Double")); Assert.AreEqual(new double[] { 1 }, reader.ReadDoubleArray("DoubleArray")); Assert.AreEqual(1, reader.ReadDecimal("Decimal")); Assert.AreEqual(new decimal?[] { 1 }, reader.ReadDecimalArray("DecimalArray")); Assert.AreEqual(Date, reader.ReadTimestamp("Timestamp")); Assert.AreEqual(new DateTime?[] { Date }, reader.ReadTimestampArray("TimestampArray")); Assert.AreEqual("1", reader.ReadString("String")); Assert.AreEqual(new[] { "1" }, reader.ReadStringArray("StringArray")); Assert.AreEqual(Guid, reader.ReadGuid("Guid")); Assert.AreEqual(new Guid?[] { Guid }, reader.ReadGuidArray("GuidArray")); Assert.AreEqual(MyEnum.Bar, reader.ReadEnum <MyEnum>("Enum")); Assert.AreEqual(new[] { MyEnum.Bar }, reader.ReadEnumArray <MyEnum>("EnumArray")); var raw = reader.GetRawReader(); Assert.AreEqual(1, raw.ReadByte()); Assert.AreEqual(new byte[] { 1 }, raw.ReadByteArray()); Assert.AreEqual('1', raw.ReadChar()); Assert.AreEqual(new[] { '1' }, raw.ReadCharArray()); Assert.AreEqual(1, raw.ReadShort()); Assert.AreEqual(new short[] { 1 }, raw.ReadShortArray()); Assert.AreEqual(1, raw.ReadInt()); Assert.AreEqual(new[] { 1 }, raw.ReadIntArray()); Assert.AreEqual(1, raw.ReadLong()); Assert.AreEqual(new long[] { 1 }, raw.ReadLongArray()); Assert.AreEqual(true, raw.ReadBoolean()); Assert.AreEqual(new[] { true }, raw.ReadBooleanArray()); Assert.AreEqual(1, raw.ReadFloat()); Assert.AreEqual(new float[] { 1 }, raw.ReadFloatArray()); Assert.AreEqual(1, raw.ReadDouble()); Assert.AreEqual(new double[] { 1 }, raw.ReadDoubleArray()); Assert.AreEqual(1, raw.ReadDecimal()); Assert.AreEqual(new decimal?[] { 1 }, raw.ReadDecimalArray()); Assert.AreEqual(Date, raw.ReadTimestamp()); Assert.AreEqual(new DateTime?[] { Date }, raw.ReadTimestampArray()); Assert.AreEqual("1", raw.ReadString()); Assert.AreEqual(new[] { "1" }, raw.ReadStringArray()); Assert.AreEqual(Guid, raw.ReadGuid()); Assert.AreEqual(new Guid?[] { Guid }, raw.ReadGuidArray()); Assert.AreEqual(MyEnum.Bar, raw.ReadEnum <MyEnum>()); Assert.AreEqual(new[] { MyEnum.Bar }, raw.ReadEnumArray <MyEnum>()); }
/// <summary> /// Reads <see cref="SuperBlock"/> from the stream. /// </summary> /// <param name="reader">Binary reader stream.</param> public static SuperBlock Read(IBinaryReader reader) { return(new SuperBlock { MagicBytes = reader.ReadByteArray(Magic.Length), BlockSize = reader.ReadUint(), FreeBlockMapBlock = reader.ReadUint(), NumBlocks = reader.ReadUint(), NumDirectoryBytes = reader.ReadUint(), Unknown1 = reader.ReadUint(), BlockMapAddr = reader.ReadUint() }); }
/** <inheritDoc /> */ void IBinarizable.ReadBinary(IBinaryReader reader) { Id = reader.ReadInt("id"); CompanyId = reader.ReadInt("companyId"); Age = reader.ReadInt("age"); Points = reader.ReadInt("points"); SexType = (Sex)reader.ReadByte("sex"); Department = (Department)reader.ReadByte("department"); Salary = reader.ReadLong("salary"); Payload = reader.ReadByteArray("payload"); Name = reader.ReadString("name"); Address = reader.ReadObject <Address>("address"); }
private static TimelinePosition ReadTimelinePosition(IBinaryReader reader) { var slice = reader.ReadInt32(); var offset = reader.ReadInt64(); var eventId = reader.ReadByteArray(EventIdSize); return(new TimelinePosition { Slice = slice, Offset = offset, EventId = eventId }); }
/// <summary> /// Reads <see cref="InlineSiteSymbol"/> from the stream. /// </summary> /// <param name="reader">Stream binary reader.</param> /// <param name="symbolStream">Symbol stream that contains this symbol record.</param> /// <param name="symbolStreamIndex">Index in symbol stream <see cref="SymbolStream.References"/> array.</param> /// <param name="kind">Symbol record kind.</param> /// <param name="dataLength">Record data length.</param> public static InlineSiteSymbol Read(IBinaryReader reader, SymbolStream symbolStream, int symbolStreamIndex, SymbolRecordKind kind, uint dataLength) { long start = reader.Position; return(new InlineSiteSymbol { SymbolStream = symbolStream, SymbolStreamIndex = symbolStreamIndex, Kind = kind, ParentOffset = reader.ReadUint(), End = reader.ReadUint(), Inlinee = TypeIndex.Read(reader), AnnotationData = reader.ReadByteArray((int)(dataLength - (reader.Position - start))), }); }
/** <inheritDoc /> */ void IBinarizable.ReadBinary(IBinaryReader reader) { Id = reader.ReadInt("id"); CompanyId = reader.ReadInt("companyId"); Age = reader.ReadInt("age"); Points = reader.ReadInt("points"); SexType = (Sex)reader.ReadByte("sex"); Department = (Department)reader.ReadByte("department"); Salary = reader.ReadLong("salary"); Payload = reader.ReadByteArray("payload"); Name = reader.ReadString("name"); Address = reader.ReadObject <Address>("address"); Birthday = reader.ReadObject <DateTime>("birthday"); Timestamp = reader.ReadTimestamp("timestamp").GetValueOrDefault(); }
/// <summary> /// Reads <see cref="CoffSectionHeader"/> from the stream. /// </summary> /// <param name="reader">Stream binary reader.</param> public static CoffSectionHeader Read(IBinaryReader reader) { return(new CoffSectionHeader { NameBytes = reader.ReadByteArray(8), VirtualSize = reader.ReadUint(), VirtualAddress = reader.ReadUint(), SizeOfRawData = reader.ReadUint(), PointerToRawData = reader.ReadUint(), PointerToRelocations = reader.ReadUint(), PointerToLinenumbers = reader.ReadUint(), NumberOfRelocations = reader.ReadUshort(), NumberOfLinenumbers = reader.ReadUshort(), Characteristics = (ImageSectionCharacteristics)reader.ReadUint(), }); }
/// <summary> /// Reads <see cref="Thunk32Symbol"/> from the stream. /// </summary> /// <param name="reader">Stream binary reader.</param> /// <param name="kind">Symbol record kind.</param> /// <param name="dataLength">Record data length.</param> public static Thunk32Symbol Read(IBinaryReader reader, SymbolRecordKind kind, uint dataLength) { long start = reader.Position; return(new Thunk32Symbol { Kind = kind, Parent = reader.ReadUint(), End = reader.ReadUint(), Next = reader.ReadUint(), Offset = reader.ReadUint(), Segment = reader.ReadUshort(), Length = reader.ReadUshort(), Ordinal = (ThunkOrdinal)reader.ReadByte(), Name = reader.ReadCString(), VariantData = reader.ReadByteArray((int)(dataLength - (reader.Position - start))), }); }
public void ReadBinary(IBinaryReader reader) { Assert.AreEqual(1, reader.ReadByte("Byte")); Assert.AreEqual(new byte[] {1}, reader.ReadByteArray("ByteArray")); Assert.AreEqual('1', reader.ReadChar("Char")); Assert.AreEqual(new[] {'1'}, reader.ReadCharArray("CharArray")); Assert.AreEqual(1, reader.ReadShort("Short")); Assert.AreEqual(new short[] {1}, reader.ReadShortArray("ShortArray")); Assert.AreEqual(1, reader.ReadInt("Int")); Assert.AreEqual(new[] {1}, reader.ReadIntArray("IntArray")); Assert.AreEqual(1, reader.ReadLong("Long")); Assert.AreEqual(new long[] {1}, reader.ReadLongArray("LongArray")); Assert.AreEqual(true, reader.ReadBoolean("Boolean")); Assert.AreEqual(new[] {true}, reader.ReadBooleanArray("BooleanArray")); Assert.AreEqual(1, reader.ReadFloat("Float")); Assert.AreEqual(new float[] {1}, reader.ReadFloatArray("FloatArray")); Assert.AreEqual(1, reader.ReadDouble("Double")); Assert.AreEqual(new double[] {1}, reader.ReadDoubleArray("DoubleArray")); Assert.AreEqual(1, reader.ReadDecimal("Decimal")); Assert.AreEqual(new decimal?[] {1}, reader.ReadDecimalArray("DecimalArray")); Assert.AreEqual(Date, reader.ReadTimestamp("Timestamp")); Assert.AreEqual(new DateTime?[] {Date}, reader.ReadTimestampArray("TimestampArray")); Assert.AreEqual("1", reader.ReadString("String")); Assert.AreEqual(new[] {"1"}, reader.ReadStringArray("StringArray")); Assert.AreEqual(Guid, reader.ReadGuid("Guid")); Assert.AreEqual(new Guid?[] {Guid}, reader.ReadGuidArray("GuidArray")); Assert.AreEqual(MyEnum.Bar, reader.ReadEnum<MyEnum>("Enum")); Assert.AreEqual(new[] {MyEnum.Bar}, reader.ReadEnumArray<MyEnum>("EnumArray")); var raw = reader.GetRawReader(); Assert.AreEqual(1, raw.ReadByte()); Assert.AreEqual(new byte[] { 1 }, raw.ReadByteArray()); Assert.AreEqual('1', raw.ReadChar()); Assert.AreEqual(new[] { '1' }, raw.ReadCharArray()); Assert.AreEqual(1, raw.ReadShort()); Assert.AreEqual(new short[] { 1 }, raw.ReadShortArray()); Assert.AreEqual(1, raw.ReadInt()); Assert.AreEqual(new[] { 1 }, raw.ReadIntArray()); Assert.AreEqual(1, raw.ReadLong()); Assert.AreEqual(new long[] { 1 }, raw.ReadLongArray()); Assert.AreEqual(true, raw.ReadBoolean()); Assert.AreEqual(new[] { true }, raw.ReadBooleanArray()); Assert.AreEqual(1, raw.ReadFloat()); Assert.AreEqual(new float[] { 1 }, raw.ReadFloatArray()); Assert.AreEqual(1, raw.ReadDouble()); Assert.AreEqual(new double[] { 1 }, raw.ReadDoubleArray()); Assert.AreEqual(1, raw.ReadDecimal()); Assert.AreEqual(new decimal?[] { 1 }, raw.ReadDecimalArray()); Assert.AreEqual(Date, raw.ReadTimestamp()); Assert.AreEqual(new DateTime?[] { Date }, raw.ReadTimestampArray()); Assert.AreEqual("1", raw.ReadString()); Assert.AreEqual(new[] { "1" }, raw.ReadStringArray()); Assert.AreEqual(Guid, raw.ReadGuid()); Assert.AreEqual(new Guid?[] { Guid }, raw.ReadGuidArray()); Assert.AreEqual(MyEnum.Bar, raw.ReadEnum<MyEnum>()); Assert.AreEqual(new[] { MyEnum.Bar }, raw.ReadEnumArray<MyEnum>()); }
public void ReadBinary(IBinaryReader reader) { this.Timestamp = reader.ReadLong(nameof(Timestamp)); this.LinkLayer = (LinkLayerType)reader.ReadInt(nameof(LinkLayer)); this.Data = reader.ReadByteArray(nameof(Data)); }
private void Initialize(IBinaryReader reader) { Reader = reader; // Parse file headers // Initialize MSF super block SuperBlock = MSF.SuperBlock.Read(Reader); SuperBlock.Validate(); if (File.Length % SuperBlock.BlockSize != 0) { throw new Exception("File size is not a multiple of block size"); } // Initialize Free Page Map. // The Fpm exists either at block 1 or block 2 of the MSF. However, this // allows for a maximum of getBlockSize() * 8 blocks bits in the Fpm, and // thusly an equal number of total blocks in the file. For a block size // of 4KiB (very common), this would yield 32KiB total blocks in file, for a // maximum file size of 32KiB * 4KiB = 128MiB. Obviously this won't do, so // the Fpm is split across the file at `getBlockSize()` intervals. As a // result, every block whose index is of the form |{1,2} + getBlockSize() * k| // for any non-negative integer k is an Fpm block. In theory, we only really // need to reserve blocks of the form |{1,2} + getBlockSize() * 8 * k|, but // current versions of the MSF format already expect the Fpm to be arranged // at getBlockSize() intervals, so we have to be compatible. // See the function fpmPn() for more information: // https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/msf/msf.cpp#L489 uint fpmIntervals = (SuperBlock.NumBlocks + 8 * SuperBlock.BlockSize - 1) / (8 * SuperBlock.BlockSize); uint[] fpmBlocks = new uint[fpmIntervals]; uint currentFpmBlock = SuperBlock.FreeBlockMapBlock; for (int i = 0; i < fpmBlocks.Length; i++) { fpmBlocks[i] = currentFpmBlock; currentFpmBlock += SuperBlock.BlockSize; } IBinaryReader fpmStream = new MappedBlockBinaryReader(fpmBlocks, SuperBlock.BlockSize, (SuperBlock.NumBlocks + 7) / 8, Reader); FreePageMap = Reader.ReadByteArray((int)fpmStream.Length); // Read directory blocks Reader.Position = (long)SuperBlock.BlockMapOffset; uint[] directoryBlocks = Reader.ReadUintArray((int)SuperBlock.NumDirectoryBlocks); // Parse stream data uint NumStreams = 0; PdbStream directoryStream = new PdbStream(directoryBlocks, SuperBlock.NumDirectoryBytes, this); NumStreams = directoryStream.Reader.ReadUint(); streams = new PdbStream[NumStreams]; uint[] streamSizes = directoryStream.Reader.ReadUintArray(streams.Length); for (int i = 0; i < streams.Length; i++) { uint streamSize = streamSizes[i]; uint NumExpectedStreamBlocks = streamSize == uint.MaxValue ? 0 : SuperBlock.BytesToBlocks(streamSize); uint[] blocks = directoryStream.Reader.ReadUintArray((int)NumExpectedStreamBlocks); foreach (uint block in blocks) { ulong blockEndOffset = SuperBlock.BlocksToBytes(block + 1); if (blockEndOffset > (ulong)File.Length) { throw new Exception("Stream block map is corrupt."); } } streams[i] = new PdbStream(blocks, streamSize, this); } if (directoryStream.Reader.Position != SuperBlock.NumDirectoryBytes) { throw new Exception("Not whole directory stream was read"); } dbiStreamCache = SimpleCache.CreateStruct(() => new DbiStream(streams[(uint)SpecialStream.StreamDBI])); infoStreamCache = SimpleCache.CreateStruct(() => new InfoStream(streams[(uint)SpecialStream.StreamPDB])); tpiStreamCache = SimpleCache.CreateStruct(() => new TpiStream(streams[(uint)SpecialStream.StreamTPI])); ipiStreamCache = SimpleCache.CreateStruct(() => new TpiStream(streams[(uint)SpecialStream.StreamIPI])); pdbSymbolStreamCache = SimpleCache.CreateStruct(() => { PdbStream stream = GetStream(DbiStream.SymbolRecordStreamIndex); if (stream != null) { return(new SymbolStream(stream)); } return(null); }); globalsStreamCache = SimpleCache.CreateStruct(() => { PdbStream stream = GetStream(DbiStream.GlobalSymbolStreamIndex); if (stream != null) { return(new GlobalsStream(stream)); } return(null); }); publicsStreamCache = SimpleCache.CreateStruct(() => { PdbStream stream = GetStream(DbiStream.Header.PublicSymbolStreamIndex); if (stream != null) { return(new PublicsStream(this, stream.Reader)); } return(null); }); }
/** <inheritDoc /> */ void IBinarizable.ReadBinary(IBinaryReader reader) { Id = reader.ReadInt("id"); CompanyId = reader.ReadInt("companyId"); Age = reader.ReadInt("age"); Points = reader.ReadInt("points"); SexType = (Sex)reader.ReadByte("sex"); Department = (Department)reader.ReadByte("department"); Salary = reader.ReadLong("salary"); Payload = reader.ReadByteArray("payload"); Name = reader.ReadString("name"); Address = reader.ReadObject<Address>("address"); }
/// <summary> /// Initializes a new instance of the <see cref="GlobalsStream"/> class. /// </summary> /// <param name="file">PDB file containing this stream.</param> /// <param name="reader">Binary stream reader.</param> public GlobalsStream(PdbFile file, IBinaryReader reader) { File = file; // Read header Header = GlobalsStreamHeader.Read(reader); if (Header.Signature != GlobalsStreamHeader.ExpectedSignature) { throw new Exception($"GSIHashHeader signature (0x{GlobalsStreamHeader.ExpectedSignature:X}) not found."); } if (Header.Version != GlobalsStreamHeader.ExpectedVersion) { throw new Exception("Encountered unsupported globals stream version."); } // Read hash records if (Header.HashRecordsSubstreamSize % GlobalsStreamHashRecord.Size != 0) { throw new Exception("Invalid hash record array size."); } if (reader.BytesRemaining < Header.HashRecordsSubstreamSize) { throw new Exception("Error reading hash records."); } GlobalsStreamHashRecord[] hashRecords = new GlobalsStreamHashRecord[Header.HashRecordsSubstreamSize / GlobalsStreamHashRecord.Size]; for (int i = 0; i < hashRecords.Length; i++) { hashRecords[i] = GlobalsStreamHashRecord.Read(reader); } HashRecords = hashRecords; // Read hash buckets if (Header.HashBucketsSubstreamSize > 0) { const uint IPHR_HASH = 4096; const uint SizeOfHROffsetCalc = 12; ulong bitmapSizeInBits = (IPHR_HASH / 32 + 1) * 32; int bitmapEntriesCount = (int)(bitmapSizeInBits / 8); if (reader.BytesRemaining < bitmapEntriesCount) { throw new Exception("Could not read a bitmap."); } byte[] hashBitmap = reader.ReadByteArray(bitmapEntriesCount); int nonEmptyBucketsCount = 0; for (int i = 0; i < hashBitmap.Length; i++) { nonEmptyBucketsCount += bitCount[hashBitmap[i]]; } if (reader.BytesRemaining < nonEmptyBucketsCount * 4) // 4 = sizeof(uint) { throw new Exception("Could not read a bitmap."); } uint[] nonEmptyBucketOffsets = reader.ReadUintArray(nonEmptyBucketsCount); GlobalsStreamHashBucket[] hashBuckets = new GlobalsStreamHashBucket[IPHR_HASH]; for (int i = 0, j = 0; i < IPHR_HASH; i++) { int byteIndex = i / 8; int bitIndex = i % 8; if ((hashBitmap[byteIndex] & (1 << bitIndex)) != 0) { uint start = nonEmptyBucketOffsets[j++] / SizeOfHROffsetCalc; uint end = j < nonEmptyBucketOffsets.Length ? nonEmptyBucketOffsets[j] / SizeOfHROffsetCalc : (uint)HashRecords.Length; hashBuckets[i] = new GlobalsStreamHashBucket { Start = (int)start, End = (int)end, }; } else { hashBuckets[i] = new GlobalsStreamHashBucket { Start = -1, End = -1, } }; } HashBuckets = hashBuckets; } Symbols = new ArrayCache <SymbolRecord>(HashRecords.Length, index => File.PdbSymbolStream.GetSymbolRecordByOffset(HashRecords[index].Offset - 1)); constantsCache = SimpleCache.CreateStruct(() => { List <ConstantSymbol> constants = new List <ConstantSymbol>(); for (int i = 0; i < Symbols.Count; i++) { ConstantSymbol constant = Symbols[i] as ConstantSymbol; if (constant != null) { constants.Add(constant); } } return(constants); }); threadLocalDataCache = SimpleCache.CreateStruct(() => { List <ThreadLocalDataSymbol> threadLocalData = new List <ThreadLocalDataSymbol>(); for (int i = 0; i < Symbols.Count; i++) { ThreadLocalDataSymbol tls = Symbols[i] as ThreadLocalDataSymbol; if (tls != null) { threadLocalData.Add(tls); } } return(threadLocalData); }); dataCache = SimpleCache.CreateStruct(() => { List <DataSymbol> data = new List <DataSymbol>(); for (int i = 0; i < Symbols.Count; i++) { DataSymbol d = Symbols[i] as DataSymbol; if (d != null) { data.Add(d); } } return(data); }); }
public void ReadBinary(IBinaryReader reader) { this.Bytes = reader.ReadByteArray(nameof(FlowKey.Bytes)); this.FlowKeyHash = reader.ReadInt(nameof(FlowKey.FlowKeyHash)); }
public void ReadBinary(IBinaryReader reader) { // Read in different order to enforce full schema scan. Int = reader.ReadInt("int"); Arr = reader.ReadByteArray("arr"); }
private static void ReadVector(IBinaryReader reader, IHerculesTagsBuilder builder, string key) { var elementType = (TagType)reader.ReadByte(); switch (elementType) { case TagType.String: builder.AddVector(key, reader.ReadArray(r => r.ReadString())); break; case TagType.Long: builder.AddVector(key, reader.ReadArray(r => r.ReadInt64())); break; case TagType.Uuid: builder.AddVector(key, reader.ReadArray(r => r.ReadGuid())); break; case TagType.Container: var elementsCount = reader.ReadInt32(); var valueBuilder = new Action <IHerculesTagsBuilder>(b => ReadContainer(reader, b)); var valueBuilders = new Action <IHerculesTagsBuilder> [elementsCount]; for (var i = 0; i < elementsCount; i++) { valueBuilders[i] = valueBuilder; } builder.AddVectorOfContainers(key, valueBuilders); break; case TagType.Integer: builder.AddVector(key, reader.ReadArray(r => r.ReadInt32())); break; case TagType.Double: builder.AddVector(key, reader.ReadArray(r => r.ReadDouble())); break; case TagType.Flag: builder.AddVector(key, reader.ReadArray(r => r.ReadBool())); break; case TagType.Byte: builder.AddVector(key, reader.ReadByteArray()); break; case TagType.Short: builder.AddVector(key, reader.ReadArray(r => r.ReadInt16())); break; case TagType.Float: builder.AddVector(key, reader.ReadArray(r => r.ReadFloat())); break; case TagType.Vector: throw new NotSupportedException("Nested vectors are not supported yet."); case TagType.Null: throw new NotSupportedException("Vectors of nulls are not supported yet."); default: throw new ArgumentOutOfRangeException(nameof(elementType), elementType, "Unexpected vector element type."); } }