コード例 #1
0
        public ReflectedMember GetDefinition(Core.COFF.MetadataTables table, int metadataRowOffset)
        {
            ReflectedMember definition = null;

            if (internalMap.ContainsKey(table))
            {
                Dictionary <int, ReflectedMember> tableStore = internalMap[table];
                if (tableStore.ContainsKey(metadataRowOffset))
                {
                    definition = tableStore[metadataRowOffset];
                }
            }
            return(definition);
        }
コード例 #2
0
        /// <include file='code-documentation\reflection.xml' path='docs/assemblydef/member[@name="resolvemetadatatoken"]/*'/>
        public ReflectedMember ResolveMetadataToken(uint metadataToken)
        {
            MetadataToDefinitionMap map            = _peCoffFile.Map;
            MetadataStream          metadataStream = _peCoffFile.GetMetadataDirectory().GetMetadataStream();

            // Get the details in the token
            ILMetadataToken token = (ILMetadataToken)(metadataToken & 0xff000000);
            uint            index = metadataToken & 0x00ffffff;

            ReflectedMember returnItem = null;

            //
            switch (token)
            {
            // Method related tokens
            case ILMetadataToken.MethodDef:
                returnItem = map.GetDefinition(MetadataTables.MethodDef, metadataStream.GetEntryFor(MetadataTables.MethodDef, index));
                break;

            case ILMetadataToken.MemberRef:
                returnItem = map.GetDefinition(MetadataTables.MemberRef, metadataStream.GetEntryFor(MetadataTables.MemberRef, index));
                break;

            case ILMetadataToken.MethodSpec:
                returnItem = map.GetDefinition(MetadataTables.MethodSpec, metadataStream.GetEntryFor(MetadataTables.MethodSpec, index));
                break;

            // Type related tokens
            case ILMetadataToken.TypeDef:
                returnItem = map.GetDefinition(MetadataTables.TypeDef, metadataStream.GetEntryFor(MetadataTables.TypeDef, index));
                break;

            case ILMetadataToken.TypeRef:
                returnItem = map.GetDefinition(MetadataTables.TypeRef, metadataStream.GetEntryFor(MetadataTables.TypeRef, index));
                break;

            case ILMetadataToken.TypeSpec:
                returnItem = map.GetDefinition(MetadataTables.TypeSpec, metadataStream.GetEntryFor(MetadataTables.TypeSpec, index));
                break;

            case ILMetadataToken.FieldDef:
                returnItem = map.GetDefinition(MetadataTables.Field, metadataStream.GetEntryFor(MetadataTables.Field, index));
                break;
            }

            return(returnItem);
        }
コード例 #3
0
 /// <summary>
 /// Initialises a new instance of the ReflectionException.
 /// </summary>
 /// <param name="member">The member associated with this exception.</param>
 /// <param name="message">Message describing the error.</param>
 /// <param name="innerException">The thrown exception.</param>
 public ReflectionException(ReflectedMember member, string message, Exception innerException)
     : base(message, innerException)
 {
     this.Member = member;
 }
コード例 #4
0
 /// <summary>
 /// Adds a new entry in to the definition map.
 /// </summary>
 /// <param name="table">The table this row and definition are from</param>
 /// <param name="metadataRow">The row the definition is associated with</param>
 /// <param name="definition">The definition the row is associated with</param>
 /// <remarks>
 /// If a table is created and no unique key is provided for it, you will not be able to use
 /// a unique key for that table at any point.
 /// </remarks>
 public void Add(Core.COFF.MetadataTables table, Core.COFF.MetadataRow metadataRow, ReflectedMember definition)
 {
     // Make sure the table store is initialised
     if (!internalMap.ContainsKey(table))
     {
         internalMap[table] = new Dictionary <int, ReflectedMember>();
     }
     internalMap[table].Add(metadataRow.FileOffset, definition);
     _uniqueCounter++;
 }