private IBC.BlobEntry ReadV1BlobEntry() { BlobType type = (BlobType)reader.ReadInt32(); reader.ReadUInt32(); // Flags. Unused here. IBC.BlobEntry blob; switch (type) { case BlobType.MetadataStringPool: case BlobType.MetadataGuidPool: case BlobType.MetadataBlobPool: case BlobType.MetadataUserStringPool: blob = ReadPoolPayload(); break; case BlobType.ParamTypeSpec: blob = ReadSignaturePayload(); break; case BlobType.ParamMethodSpec: // V1 data used a special prefix to indicate method signatures. // It's not obvious why this was necessary given that the type // field already contains this information; in any event, the // prefix is removed here by passing true. blob = ReadSignaturePayload(true); break; case BlobType.EndOfBlobStream: blob = new IBC.BlobEntry.EndOfStreamEntry(); break; default: throw new IBCException("Unexpected blob type in V1 file."); } blob.Token = 0; // V1 files didn't store tokens for blob entries. blob.Type = type; return(blob); }
private IBC.BlobEntry ReadBlobEntry() { int size; long startPosition = ReadSizeAndGetStart(out size); BlobType type = (BlobType)ReadSmallInt(); uint token = ReadTokenWithMemory(ref lastTokens.LastBlobToken); IBC.BlobEntry blob; // The "Read...Payload" functions create objects of the right type and // populate the type-specific information from the stream. The // fields common to all blob entries (read above) are set after // the object is returned. switch (type) { case BlobType.MetadataStringPool: case BlobType.MetadataGuidPool: case BlobType.MetadataBlobPool: case BlobType.MetadataUserStringPool: blob = ReadPoolPayload(); break; case BlobType.ParamTypeSpec: case BlobType.ParamMethodSpec: blob = ReadSignaturePayload(); break; case BlobType.ExternalNamespaceDef: blob = ReadExternalNamespacePayload(); break; case BlobType.ExternalTypeDef: blob = ReadExternalTypePayload(); break; case BlobType.ExternalSignatureDef: blob = ReadExternalSignaturePayload(); break; case BlobType.ExternalMethodDef: blob = ReadExternalMethodPayload(); break; case BlobType.EndOfBlobStream: blob = new IBC.BlobEntry.EndOfStreamEntry(); break; default: long read = CurrentPosition - startPosition; byte[] data = reader.ReadBytes((int)size - (int)read); blob = new IBC.BlobEntry.UnknownEntry { Payload = data }; break; } blob.Token = token; blob.Type = type; SeekTo(startPosition + size); return(blob); }