/// <summary> /// Loads the signature. /// </summary> /// <param name="provider">The provider.</param> /// <param name="token">The token.</param> public void LoadSignature(IMetadataProvider provider, HeapIndexToken token) { SignatureReader reader = new SignatureReader(provider.ReadBlob(token)); ParseSignature(reader); Debug.Assert(reader.Index == reader.Length, "Signature parser didn't complete."); }
/// <summary> /// Initializes a new instance of the <see cref="RuntimeParameter"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="position">The position.</param> /// <param name="attributes">The attributes.</param> public RuntimeParameter(string name, int position, ParameterAttributes attributes) { this.token = (HeapIndexToken)0; this.attributes = attributes; this.name = name; this.position = position; }
/// <summary> /// Initializes a new instance of the <see cref="RuntimeAttribute"/> class. /// </summary> /// <param name="typeModule">The type module.</param> /// <param name="ctor">The ctor.</param> /// <param name="ctorMethod">The ctor method.</param> /// <param name="blobIndex">Index of the blob.</param> public RuntimeAttribute(ITypeModule typeModule, Token ctor, RuntimeMethod ctorMethod, HeapIndexToken blobIndex) { this.typeModule = typeModule; this.ctorMethod = ctorMethod; this.ctor = ctor; this.blobIndex = blobIndex; }
protected int CheckName(HeapIndexToken nameIndex) { if (nameIndex == 0) { return 1; } else { if (!IsValidStringIndex(nameIndex)) { return 2; } else { string name = metadata.ReadString(nameIndex); if (string.IsNullOrEmpty(name)) { return 3; } } } return 0; }
/// <summary> /// Initializes a new instance of the <see cref="GenericParamRow" /> struct. /// </summary> /// <param name="number">The number.</param> /// <param name="flags">The flags.</param> /// <param name="owner">The owner.</param> /// <param name="nameString">The name string.</param> public GenericParamRow(ushort number, GenericParameterAttributes flags, Token owner, HeapIndexToken nameString) { Number = number; Flags = flags; Owner = owner; NameString = nameString; }
/// <summary> /// Initializes a new instance of the <see cref="GenericParamRow"/> struct. /// </summary> /// <param name="number">The number.</param> /// <param name="flags">The flags.</param> /// <param name="owner">The owner table idx.</param> /// <param name="nameStringIdx">The name string idx.</param> public GenericParamRow(ushort number, GenericParameterAttributes flags, Token owner, HeapIndexToken nameStringIdx) { this.number = number; this.flags = flags; this.owner = owner; this.nameStringIdx = nameStringIdx; }
/// <summary> /// Loads the signature. /// </summary> /// <param name="signature">The signature.</param> public Signature(Signature signature) { if (signature == null) throw new ArgumentNullException(@"signature"); this.token = signature.token; }
/// <summary> /// Retrieves the string at the requested offset. /// </summary> /// <param name="token">The offset into the heap, where the string starts.</param> /// <returns>The string at the given offset.</returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.UserString); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.UserString) throw new ArgumentException(@"Invalid token value.", @"token"); int offset = (int)(token & HeapIndexToken.RowIndexMask); // Argument checks if (0 == offset) { token += 1; return String.Empty; } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); int length = CalculatePrefixLength(ref realOffset); Debug.Assert(1 == (length & 1), @"Invalid string length read from Metadata - corrupt string?"); if (0 == length) return String.Empty; byte[] buffer = this.Metadata; return Encoding.Unicode.GetString(buffer, realOffset, length - 1); }
/// <summary> /// Retrieves the string at the requested offset. /// </summary> /// <param name="token">The offset into the heap, where the string starts.</param> /// <returns>The string at the given offset.</returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.UserString); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.UserString) { throw new ArgumentException(@"Invalid token value.", @"token"); } int offset = (int)(token & HeapIndexToken.RowIndexMask); // Argument checks if (0 == offset) { token += 1; return(String.Empty); } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); int length = CalculatePrefixLength(ref realOffset); Debug.Assert(1 == (length & 1), @"Invalid string length read from Metadata - corrupt string?"); if (0 == length) { return(String.Empty); } byte[] buffer = this.Metadata; return(Encoding.Unicode.GetString(buffer, realOffset, length - 1)); }
/// <summary> /// Retrieves the blob at the specified offset. /// </summary> /// <param name="token">The token where the blob begins.</param> /// <returns>A byte array, which represents the blob at the specified location.</returns> public byte[] ReadBlob(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.Blob); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.Blob) { throw new ArgumentException("Invalid token value.", @"token"); } // Argument checks int offset = (int)(token & HeapIndexToken.RowIndexMask); if (offset == 0) { token += 1; return(emptyArray); } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); int length = CalculatePrefixLength(ref realOffset); byte[] result = new byte[length]; Array.Copy(this.Metadata, realOffset, result, 0, length); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ImplMapRow"/> struct. /// </summary> /// <param name="mappingFlags">The mapping flags.</param> /// <param name="memberForwardedTableIdx">The member forwarded table idx.</param> /// <param name="importNameStringIdx">The import name string idx.</param> /// <param name="importScopeTableIdx">The import scope table idx.</param> public ImplMapRow(PInvokeAttributes mappingFlags, Token memberForwardedTableIdx, HeapIndexToken importNameStringIdx, Token importScopeTableIdx) { _mappingFlags = mappingFlags; _memberForwardedTableIdx = memberForwardedTableIdx; _importNameStringIdx = importNameStringIdx; _importScopeTableIdx = importScopeTableIdx; }
/// <summary> /// Initializes a new instance of the <see cref="ManifestResourceRow"/> struct. /// </summary> /// <param name="offset">The offset.</param> /// <param name="flags">The flags.</param> /// <param name="nameStringIndex">Index of the name string.</param> /// <param name="implementation">The implementation table idx.</param> public ManifestResourceRow(uint offset, ManifestResourceAttributes flags, HeapIndexToken nameStringIndex, Token implementation) { _offset = offset; _flags = flags; _nameStringIdx = nameStringIndex; _implementation = implementation; }
/// <summary> /// Initializes a new instance of the <see cref="ManifestResourceRow" /> struct. /// </summary> /// <param name="offset">The offset.</param> /// <param name="flags">The flags.</param> /// <param name="nameString">Index of the name string.</param> /// <param name="implementation">The implementation.</param> public ManifestResourceRow(uint offset, ManifestResourceAttributes flags, HeapIndexToken nameString, Token implementation) { Offset = offset; Flags = flags; NameString = nameString; Implementation = implementation; }
/// <summary> /// Initializes a new instance of the <see cref="ImplMapRow" /> struct. /// </summary> /// <param name="mappingFlags">The mapping flags.</param> /// <param name="memberForwarded">The member forwarded table.</param> /// <param name="importNameString">The import name string.</param> /// <param name="importScopeTable">The import scope table.</param> public ImplMapRow(PInvokeAttributes mappingFlags, Token memberForwarded, HeapIndexToken importNameString, Token importScopeTable) { MappingFlags = mappingFlags; MemberForwarded = memberForwarded; ImportNameString = importNameString; ImportScopeTable = importScopeTable; }
/// <summary> /// Loads the signature. /// </summary> /// <param name="provider">The provider.</param> /// <param name="token">The token.</param> public Signature(IMetadataProvider provider, HeapIndexToken token) { SignatureReader reader = new SignatureReader(provider.ReadBlob(token)); this.ParseSignature(reader); Debug.Assert(reader.Index == reader.Length, @"Signature parser didn't complete."); this.token = token; }
/// <summary> /// Initializes a new instance of the <see cref="ExportedTypeRow"/> struct. /// </summary> /// <param name="flags">The flags.</param> /// <param name="typeDef">The type def.</param> /// <param name="typeName">Name of the type.</param> /// <param name="typeNamespace">The type namespace.</param> /// <param name="implementation">The implementation.</param> public ExportedTypeRow(TypeAttributes flags, HeapIndexToken typeDef, HeapIndexToken typeName, HeapIndexToken typeNamespace, Token implementation) { Flags = flags; TypeDef = typeDef; TypeName = typeName; TypeNamespace = typeNamespace; Implementation = implementation; }
/// <summary> /// Loads the signature. /// </summary> /// <param name="signature">The signature.</param> public Signature(Signature signature) { if (signature == null) { throw new ArgumentNullException(@"signature"); } this.token = signature.token; }
/// <summary> /// Initializes a new instance of the <see cref="ExportedTypeRow"/> struct. /// </summary> /// <param name="flags">The flags.</param> /// <param name="typeDef">The type def.</param> /// <param name="typeName">Name of the type.</param> /// <param name="typeNamespace">The type namespace.</param> /// <param name="implementation">The implementation.</param> public ExportedTypeRow(TypeAttributes flags, HeapIndexToken typeDef, HeapIndexToken typeName, HeapIndexToken typeNamespace, Token implementation) { this.flags = flags; this.typeDef = typeDef; this.typeName = typeName; this.typeNamespace = typeNamespace; this.implementation = implementation; }
/// <summary> /// Initializes a new instance of the <see cref="TypeDefRow" /> struct. /// </summary> /// <param name="flags">The flags.</param> /// <param name="typeName">Name of the type.</param> /// <param name="typeNamespace">The type namespace.</param> /// <param name="extends">The extends.</param> /// <param name="fieldList">The field list.</param> /// <param name="methodList">The method list.</param> public TypeDefRow(TypeAttributes flags, HeapIndexToken typeName, HeapIndexToken typeNamespace, Token extends, Token fieldList, Token methodList) { Flags = flags; TypeName = typeName; TypeNamespace = typeNamespace; Extends = extends; FieldList = fieldList; MethodList = methodList; }
/// <summary> /// Initializes a new instance of the <see cref="TypeDefRow"/> struct. /// </summary> /// <param name="flags">The flags.</param> /// <param name="typeNameIdx">The type name idx.</param> /// <param name="typeNamespaceIdx">The type namespace idx.</param> /// <param name="extends">The extends.</param> /// <param name="fieldList">The field list.</param> /// <param name="methodList">The method list.</param> public TypeDefRow(TypeAttributes flags, HeapIndexToken typeNameIdx, HeapIndexToken typeNamespaceIdx, Token extends, Token fieldList, Token methodList) { this.flags = flags; this.typeNameIdx = typeNameIdx; this.typeNamespaceIdx = typeNamespaceIdx; this.extends = extends; this.fieldList = fieldList; this.methodList = methodList; }
/// <summary> /// Initializes a new instance of the <see cref="MethodDefRow"/> struct. /// </summary> /// <param name="rva">The rva.</param> /// <param name="implFlags">The impl flags.</param> /// <param name="flags">The flags.</param> /// <param name="nameStringIdx">The name string idx.</param> /// <param name="signatureBlobIdx">The signature BLOB idx.</param> /// <param name="paramList">The param list.</param> public MethodDefRow(uint rva, MethodImplAttributes implFlags, MethodAttributes flags, HeapIndexToken nameStringIdx, HeapIndexToken signatureBlobIdx, Token paramList) { this._rva = rva; this._implFlags = implFlags; this._flags = flags; this._nameStringIdx = nameStringIdx; this._signatureBlobIdx = signatureBlobIdx; this._paramList = paramList; }
/// <summary> /// Initializes a new instance of the <see cref="MethodDefRow"/> struct. /// </summary> /// <param name="rva">The rva.</param> /// <param name="implFlags">The impl flags.</param> /// <param name="flags">The flags.</param> /// <param name="paramList">The param list.</param> public MethodDefRow(uint rva, MethodImplAttributes implFlags, MethodAttributes flags, HeapIndexToken nameString, HeapIndexToken signatureBlob, Token paramList) { Rva = rva; ImplFlags = implFlags; Flags = flags; NameString = nameString; SignatureBlob = signatureBlob; ParamList = paramList; }
/// <summary> /// Reads the string. /// </summary> /// <param name="token">The token.</param> /// <returns></returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.String); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.String) throw new ArgumentException(@"Invalid token value.", @"token"); int size = 0; // Offset of the requested string return ReadString((int)(token & HeapIndexToken.RowIndexMask), out size); }
/// <summary> /// Initializes a new instance of the <see cref="ModuleRow" /> struct. /// </summary> /// <param name="generation">The generation.</param> /// <param name="nameString">The name string.</param> /// <param name="mvidGuid">The mvid unique identifier.</param> /// <param name="encIdGuid">The enc identifier unique identifier.</param> /// <param name="encBaseIdGuid">The enc base identifier unique identifier.</param> public ModuleRow(ushort generation, HeapIndexToken nameString, HeapIndexToken mvidGuid, HeapIndexToken encIdGuid, HeapIndexToken encBaseIdGuid) { Generation = generation; NameString = nameString; MvidGuid = mvidGuid; EncIdGuid = encIdGuid; EncBaseIdGuid = encBaseIdGuid; }
/// <summary> /// Initializes a new instance of the <see cref="ModuleRow"/> struct. /// </summary> /// <param name="generation">The generation.</param> /// <param name="nameStringIdx">The name string idx.</param> /// <param name="mvidGuidIdx">The mvid GUID idx.</param> /// <param name="encIdGuidIdx">The enc id GUID idx.</param> /// <param name="encBaseIdGuidIdx">The enc base id GUID idx.</param> public ModuleRow(ushort generation, HeapIndexToken nameStringIdx, HeapIndexToken mvidGuidIdx, HeapIndexToken encIdGuidIdx, HeapIndexToken encBaseIdGuidIdx) { _generation = generation; _nameStringIdx = nameStringIdx; _mvidGuidIdx = mvidGuidIdx; _encIdGuidIdx = encIdGuidIdx; _encBaseIdGuidIdx = encBaseIdGuidIdx; }
private T RetrieveSignature <T>(HeapIndexToken blobIdx) where T : Signature { Signature signature; if (signatures.TryGetValue(blobIdx, out signature)) { return(signature as T); } else { return((T)null); } }
/// <summary> /// Reads the string. /// </summary> /// <param name="token">The token.</param> /// <returns></returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.String); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.String) { throw new ArgumentException(@"Invalid token value.", @"token"); } int size = 0; // Offset of the requested string return(ReadString((int)(token & HeapIndexToken.RowIndexMask), out size)); }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyRow"/> struct. /// </summary> /// <param name="hashAlgId">The hash alg id.</param> /// <param name="majorVersion">The major version.</param> /// <param name="minorVersion">The minor version.</param> /// <param name="buildNumber">The build number.</param> /// <param name="revision">The revision.</param> /// <param name="flags">The flags.</param> /// <param name="publicKey">The public key.</param> /// <param name="name">The name.</param> /// <param name="culture">The culture.</param> public AssemblyRow(AssemblyHashAlgorithm hashAlgId, ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision, AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture) { HashAlgId = hashAlgId; MajorVersion = majorVersion; MinorVersion = minorVersion; BuildNumber = buildNumber; Revision = revision; Flags = flags; PublicKey = publicKey; Name = name; Culture = culture; }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyRow"/> struct. /// </summary> /// <param name="hashAlgId">The hash alg id.</param> /// <param name="majorVersion">The major version.</param> /// <param name="minorVersion">The minor version.</param> /// <param name="buildNumber">The build number.</param> /// <param name="revision">The revision.</param> /// <param name="flags">The flags.</param> /// <param name="publicKey">The public key.</param> /// <param name="name">The name.</param> /// <param name="culture">The culture.</param> public AssemblyRow(AssemblyHashAlgorithm hashAlgId, ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision, AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture) { this.hashAlgId = hashAlgId; this.majorVersion = majorVersion; this.minorVersion = minorVersion; this.buildNumber = buildNumber; this.revisionNumber = revision; this.flags = flags; this.publicKey = publicKey; this.name = name; this.culture = culture; }
private string GetString(HeapIndexToken stringIdx) { string value; if (strings.TryGetValue(stringIdx, out value)) { return(value); } value = metadataProvider.ReadString(stringIdx); strings.Add(stringIdx, value); return(value); }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct. /// </summary> /// <param name="majorVersion">The major version.</param> /// <param name="minorVersion">The minor version.</param> /// <param name="buildNumber">The build number.</param> /// <param name="revisionNumber">The revision number.</param> /// <param name="flags">The flags.</param> /// <param name="publicKeyOrToken">The public key or token.</param> /// <param name="name">The name.</param> /// <param name="culture">The culture.</param> /// <param name="hashValue">The hash value.</param> public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber, AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name, HeapIndexToken culture, HeapIndexToken hashValue) { this.majorVersion = majorVersion; this.minorVersion = minorVersion; this.buildNumber = buildNumber; this.revisionNumber = revisionNumber; this.flags = flags; this.publicKeyOrToken = publicKeyOrToken; this.name = name; this.culture = culture; this.hashValue = hashValue; }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyRefRow"/> struct. /// </summary> /// <param name="majorVersion">The major version.</param> /// <param name="minorVersion">The minor version.</param> /// <param name="buildNumber">The build number.</param> /// <param name="revisionNumber">The revision number.</param> /// <param name="flags">The flags.</param> /// <param name="publicKeyOrToken">The public key or token.</param> /// <param name="name">The name.</param> /// <param name="culture">The culture.</param> /// <param name="hashValue">The hash value.</param> public AssemblyRefRow(ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revisionNumber, AssemblyAttributes flags, HeapIndexToken publicKeyOrToken, HeapIndexToken name, HeapIndexToken culture, HeapIndexToken hashValue) { MajorVersion = majorVersion; MinorVersion = minorVersion; BuildNumber = buildNumber; RevisionNumber = revisionNumber; Flags = flags; PublicKeyOrToken = publicKeyOrToken; Name = name; Culture = culture; HashValue = hashValue; }
/// <summary> /// Retrieves the GUID at the requested position in the heap. /// </summary> /// <param name="token">The Guid token, of the guid to retrieve.</param> /// <returns>The GUID at the specified location.</returns> public Guid ReadGuid(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.Guid); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.Guid) throw new ArgumentException(@"Invalid token value.", @"token"); int index = (int)(token & HeapIndexToken.RowIndexMask); if (0 >= index--) return Guid.Empty; // Validate the offset & calculate the real offset int realOffset = ValidateOffset(index * 16); byte[] buffer = this.Buffer; return new Guid(BitConverter.ToInt32(buffer, realOffset), BitConverter.ToInt16(buffer, realOffset + 4), BitConverter.ToInt16(buffer, realOffset + 6), buffer[realOffset + 8], buffer[realOffset + 9], buffer[realOffset + 10], buffer[realOffset + 11], buffer[realOffset + 12], buffer[realOffset + 13], buffer[realOffset + 14], buffer[realOffset + 8]); }
/// <summary> /// Determines whether [is same signature] [the specified metadata]. /// </summary> /// <param name="metadata">The metadata.</param> /// <param name="sig1">The sig1.</param> /// <param name="sig2">The sig2.</param> /// <returns> /// <c>true</c> if [is same signature] [the specified metadata]; otherwise, <c>false</c>. /// </returns> private bool IsSameSignature(IMetadataProvider metadata, HeapIndexToken sig1, HeapIndexToken sig2) { byte[] src = metadata.ReadBlob(sig1); byte[] dst = metadata.ReadBlob(sig2); bool result = (src.Length == dst.Length); if (result) { for (int i = 0; result && i < src.Length; i++) { result = (src[i] == dst[i]); } } return(result); }
/// <summary> /// Reads the string. /// </summary> /// <param name="token">The token.</param> /// <returns></returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.String); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.String) throw new ArgumentException(@"Invalid token value.", @"token"); // Offset of the requested string int offset = (int)(token & HeapIndexToken.RowIndexMask); if (offset == 0) return String.Empty; // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); byte[] buffer = this.Buffer; int endOffset = Array.IndexOf<byte>(buffer, 0, realOffset); return Encoding.UTF8.GetString(buffer, realOffset, endOffset - realOffset); }
protected int CheckCulture(HeapIndexToken cultureIndex) { if (cultureIndex != 0) { string culture = metadata.ReadString(cultureIndex); if (!string.IsNullOrEmpty(culture)) { if (IsValidCulture(culture)) { return 1; } } } return 0; }
/// <summary> /// Retrieves the blob at the specified offset. /// </summary> /// <param name="token">The token where the blob begins.</param> /// <returns>A byte array, which represents the blob at the specified location.</returns> public byte[] ReadBlob(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.Blob); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.Blob) throw new ArgumentException(@"Invalid token value.", @"token"); // Argument checks int offset = (int)(token & HeapIndexToken.RowIndexMask); if (0 == offset) { token += 1; return new byte[0]; } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); int length = CalculatePrefixLength(ref realOffset); byte[] result = new byte[length]; Array.Copy(this.Buffer, realOffset, result, 0, length); return result; }
/// <summary> /// Retrieves the GUID at the requested position in the heap. /// </summary> /// <param name="token">The Guid token, of the guid to retrieve.</param> /// <returns>The GUID at the specified location.</returns> public Guid ReadGuid(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.Guid); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.Guid) { throw new ArgumentException(@"Invalid token value.", @"token"); } int index = (int)(token & HeapIndexToken.RowIndexMask); if (0 >= index--) { return(Guid.Empty); } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(index * 16); byte[] buffer = this.Buffer; return(new Guid(BitConverter.ToInt32(buffer, realOffset), BitConverter.ToInt16(buffer, realOffset + 4), BitConverter.ToInt16(buffer, realOffset + 6), buffer[realOffset + 8], buffer[realOffset + 9], buffer[realOffset + 10], buffer[realOffset + 11], buffer[realOffset + 12], buffer[realOffset + 13], buffer[realOffset + 14], buffer[realOffset + 8])); }
/// <summary> /// Read and decode an index value from the reader. /// </summary> /// <param name="reader">The reader to read From.</param> /// <param name="index">The index type to read.</param> /// <returns>The index value.</returns> private HeapIndexToken ReadHeapToken(BinaryReader reader, IndexType index) { HeapIndexToken value = (HeapIndexToken)(GetIndexSize(index) == 2 ? (0x0000FFFF & (int)reader.ReadInt16()) : reader.ReadInt32()); switch (index) { case IndexType.StringHeap: value |= HeapIndexToken.String; break; case IndexType.GuidHeap: value |= HeapIndexToken.Guid; break; case IndexType.BlobHeap: value |= HeapIndexToken.Blob; break; default: throw new ArgumentException(@"Invalid IndexType."); } return(value); }
/// <summary> /// Reads the string. /// </summary> /// <param name="token">The token.</param> /// <returns></returns> public string ReadString(HeapIndexToken token) { Debug.Assert((HeapIndexToken.TableMask & token) == HeapIndexToken.String); if ((HeapIndexToken.TableMask & token) != HeapIndexToken.String) { throw new ArgumentException(@"Invalid token value.", @"token"); } // Offset of the requested string int offset = (int)(token & HeapIndexToken.RowIndexMask); if (0 == offset) { return(String.Empty); } // Validate the offset & calculate the real offset int realOffset = ValidateOffset(offset); byte[] buffer = this.Buffer; int endOffset = Array.IndexOf <byte>(buffer, 0, realOffset); return(Encoding.UTF8.GetString(buffer, realOffset, endOffset - realOffset)); }
/// <summary> /// Initializes a new instance of the <see cref="StandAloneSigRow"/> struct. /// </summary> /// <param name="signatureBlobIdx">The signature BLOB idx.</param> public StandAloneSigRow(HeapIndexToken signatureBlobIdx) { _signatureBlobIdx = signatureBlobIdx; }
/// <summary> /// Initializes a new instance of the <see cref="EventRow"/> struct. /// </summary> /// <param name="flags">The flags.</param> /// <param name="name">The name.</param> /// <param name="eventType">Type of the event.</param> public EventRow(EventAttributes flags, HeapIndexToken name, Token eventType) { this.flags = flags; this.name = name; this.eventType = eventType; }