当前位置: 首页>>代码示例>>C#>>正文


C# MetadataObject类代码示例

本文整理汇总了C#中MetadataObject的典型用法代码示例。如果您正苦于以下问题:C# MetadataObject类的具体用法?C# MetadataObject怎么用?C# MetadataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MetadataObject类属于命名空间,在下文中一共展示了MetadataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FieldSignatureConverter

 internal FieldSignatureConverter(PEFileToObjectModel peFileToObjectModel, MetadataObject moduleField, MemoryReader signatureMemoryReader)
     : base(peFileToObjectModel, signatureMemoryReader, moduleField)
 {
     //^ base;
       //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary.
       this.FirstByte = this.SignatureMemoryReader.ReadByte();
       if (!SignatureHeader.IsFieldSignature(this.FirstByte)) {
     //  Error...
       }
       bool isPinned;
       this.customModifiers = this.GetCustomModifiers(out isPinned);
       this.TypeReference = this.GetTypeReference();
 }
开发者ID:riverar,项目名称:devtools,代码行数:13,代码来源:PEFileToObjectModel.cs

示例2: GetCustomAttributeAtRow

 internal ICustomAttribute GetCustomAttributeAtRow(
   MetadataObject owningObject,
   uint token,
   uint customAttributeRowId
 ) {
   if (customAttributeRowId == 0 || customAttributeRowId > this.PEFileReader.CustomAttributeTable.NumberOfRows) {
     //  MD Error
     return Dummy.CustomAttribute;
   }
   if (this.CustomAttributeArray[customAttributeRowId] == null) {
     lock (GlobalLock.LockingObject) {
       if (this.CustomAttributeArray[customAttributeRowId] == null) {
         CustomAttributeRow customAttribute = this.PEFileReader.CustomAttributeTable[customAttributeRowId];
         if (customAttribute.Parent == token || (customAttribute.Parent == 1 && token == TokenTypeIds.Assembly+1)) {
           uint ctorTokenType = customAttribute.Type & TokenTypeIds.TokenTypeMask;
           uint ctorRowId = customAttribute.Type & TokenTypeIds.RIDMask;
           IMethodReference/*?*/ moduleMethodReference = null;
           if (ctorTokenType == TokenTypeIds.MethodDef) {
             moduleMethodReference = this.GetMethodDefAtRow(ctorRowId);
           } else if (ctorTokenType == TokenTypeIds.MemberRef) {
             moduleMethodReference = this.GetModuleMemberReferenceAtRow(owningObject, ctorRowId) as IMethodReference;
           }
           if (moduleMethodReference == null) {
             //  TODO: MDError
             this.CustomAttributeArray[customAttributeRowId] = Dummy.CustomAttribute;
             return Dummy.CustomAttribute;
           }
           this.currentOwningObject = owningObject;
           if (customAttribute.Value == 0) {
             this.CustomAttributeArray[customAttributeRowId] = 
               this.ModuleReader.metadataReaderHost.Rewrite(this.Module, new CustomAttribute(this, customAttributeRowId, moduleMethodReference, null, null));
           } else {
             //  TODO: Check if customAttribute.Value is within the range
             MemoryBlock signatureMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(customAttribute.Value);
             //  TODO: Error checking enough space in signature memoryBlock.
             MemoryReader memoryReader = new MemoryReader(signatureMemoryBlock);
             this.ModuleReader.metadataReaderHost.StartGuessingGame();
             CustomAttributeDecoder customAttrDecoder = new CustomAttributeDecoder(this, memoryReader, customAttributeRowId, moduleMethodReference);
             while (customAttrDecoder.decodeFailed && this.ModuleReader.metadataReaderHost.TryNextPermutation())
               customAttrDecoder = new CustomAttributeDecoder(this, memoryReader, customAttributeRowId, moduleMethodReference);
             if (!customAttrDecoder.decodeFailed)
               this.ModuleReader.metadataReaderHost.WinGuessingGame();
             //else
             //TODO: error
             this.CustomAttributeArray[customAttributeRowId] = customAttrDecoder.CustomAttribute;
           }
         } else {
           //  MD Error
           this.CustomAttributeArray[customAttributeRowId] = Dummy.CustomAttribute;
         }
       }
     }
   }
   ICustomAttribute/*?*/ ret = this.CustomAttributeArray[customAttributeRowId];
   //^ assert ret != null;
   return ret;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:57,代码来源:PEFileToObjectModel.cs

示例3: GetCustomAttributeInfo

 internal void GetCustomAttributeInfo(
   MetadataObject metadataObject,
   out uint customAttributeRowIdStart,
   out uint customAttributeRowIdEnd
 ) {
   customAttributeRowIdStart = 0;
   customAttributeRowIdEnd = 0;
   if (metadataObject.TokenValue == 0xFFFFFFFF)
     return;
   uint customAttributeCount;
   customAttributeRowIdStart = this.PEFileReader.CustomAttributeTable.FindCustomAttributesForToken(metadataObject.TokenValue, out customAttributeCount);
   customAttributeRowIdEnd = customAttributeRowIdStart + customAttributeCount;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:13,代码来源:PEFileToObjectModel.cs

示例4: GetReferenceForToken

 //  Caller must lock this...
 internal object/*?*/ GetReferenceForToken(
   MetadataObject owningObject,
   uint token
 ) {
   uint tokenKind = token & TokenTypeIds.TokenTypeMask;
   uint rowId = token & TokenTypeIds.RIDMask;
   switch (tokenKind) {
     case TokenTypeIds.TypeDef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeDefTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeDefinitionAtRow(rowId);
       }
     case TokenTypeIds.TypeRef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeRefTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeRefReferenceAtRow(rowId);
       }
     case TokenTypeIds.TypeSpec: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeSpecTable.NumberOfRows) {
           //  handle Error
           return null;
         }
         return this.GetTypeSpecReferenceAtRow(owningObject, rowId).UnderlyingModuleTypeReference;
       }
     case TokenTypeIds.MethodDef:
       if (rowId == 0 || rowId > this.PEFileReader.MethodTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetMethodDefAtRow(rowId);
     case TokenTypeIds.FieldDef:
       if (rowId == 0 || rowId > this.PEFileReader.FieldTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetFieldDefAtRow(rowId);
     case TokenTypeIds.MemberRef:
       if (rowId == 0 || rowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetModuleMemberReferenceAtRow(owningObject, rowId);
     case TokenTypeIds.MethodSpec:
       if (rowId == 0 || rowId > this.PEFileReader.MethodSpecTable.NumberOfRows) {
         //  handle Error
         return null;
       }
       return this.GetMethodSpecAtRow(owningObject, rowId);
     default:
       return null;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:57,代码来源:PEFileToObjectModel.cs

示例5: GetFieldReferenceForToken

 //  Caller should lock this...
 internal IFieldReference GetFieldReferenceForToken(
   MetadataObject owningObject,
   uint fieldRefToken
 ) {
   uint tokenKind = fieldRefToken & TokenTypeIds.TokenTypeMask;
   uint rowId = fieldRefToken & TokenTypeIds.RIDMask;
   switch (tokenKind) {
     case TokenTypeIds.FieldDef:
       FieldDefinition/*?*/ fieldDef = this.GetFieldDefAtRow(rowId);
       if (fieldDef == null)
         return Dummy.FieldReference;
       else
         return fieldDef;
     case TokenTypeIds.MemberRef: {
         var fieldRef = this.GetModuleMemberReferenceAtRow(owningObject, rowId) as IFieldReference;
         if (fieldRef == null) {
           //  MDError/ILError?
           return Dummy.FieldReference;
         } else {
           return fieldRef;
         }
       }
     default:
       return Dummy.FieldReference;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:27,代码来源:PEFileToObjectModel.cs

示例6: GetMethodReferenceForToken

 //  Caller should lock this...
 internal IMethodReference GetMethodReferenceForToken(
   MetadataObject owningObject,
   uint methodRefToken
 ) {
   uint tokenKind = methodRefToken & TokenTypeIds.TokenTypeMask;
   uint rowId = methodRefToken & TokenTypeIds.RIDMask;
   IMethodReference/*?*/ methRef = null;
   switch (tokenKind) {
     case TokenTypeIds.MethodDef:
       methRef = this.GetMethodDefAtRow(rowId);
       break;
     case TokenTypeIds.MethodSpec:
       methRef = this.GetMethodSpecAtRow(owningObject, rowId);
       break;
     case TokenTypeIds.MemberRef:
       methRef = this.GetModuleMemberReferenceAtRow(owningObject, rowId) as IMethodReference;
       break;
   }
   if (methRef == null) {
     //  Error...
     methRef = Dummy.MethodReference;
   }
   return methRef;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:25,代码来源:PEFileToObjectModel.cs

示例7: GetModuleMemberReferenceAtRowWorker

    //^ invariant this.PEFileReader.MethodSpecTable.NumberOfRows >= 1 ==> this.MethodSpecHashtable != null;

    internal MemberReference/*?*/ GetModuleMemberReferenceAtRowWorker(
      MetadataObject owningObject,
      uint memberRefRowId
    ) {
      if (memberRefRowId == 0 || memberRefRowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
        return null;
      }
      if (this.ModuleMemberReferenceArray[memberRefRowId] == null) {
        MemberRefRow memberRefRow = this.PEFileReader.MemberRefTable[memberRefRowId];
        uint classTokenType = memberRefRow.Class & TokenTypeIds.TokenTypeMask;
        uint classRowId = memberRefRow.Class & TokenTypeIds.RIDMask;
        IModuleTypeReference/*?*/ parentTypeReference = null;
        switch (classTokenType) {
          case TokenTypeIds.TypeDef:
            parentTypeReference = this.GetTypeDefinitionAtRowWorker(classRowId);
            break;
          case TokenTypeIds.TypeRef:
            parentTypeReference = this.GetTypeRefReferenceAtRowWorker(classRowId);
            break;
          case TokenTypeIds.TypeSpec:
            parentTypeReference = this.GetTypeSpecReferenceAtRow(owningObject, classRowId).UnderlyingModuleTypeReference;
            break;
          case TokenTypeIds.MethodDef: {
              MethodDefinition/*?*/ methodDef = this.GetMethodDefAtRow(classRowId);
              if (methodDef == null) {
                //  Error...
                return null;
              }
              parentTypeReference = methodDef.OwningModuleType;
              break;
            }
          case TokenTypeIds.ModuleRef: {
              ModuleReference/*?*/ modRef = this.GetModuleReferenceAt(classRowId);
              if (modRef == null) {
                //  MDError
                return null;
              }
              Module/*?*/ module = this.ResolveModuleRefReference(modRef);
              if (module == null) {
                //TODO: MDError...
                return null;
              }
              PEFileToObjectModel modulePEFileToObjectModel = module.PEFileToObjectModel;
              parentTypeReference = modulePEFileToObjectModel._Module_;
              break;
            }
          default: {
              //  MDError...
              return null;
            }
        }
        if (parentTypeReference == null) {
          //  Error...
          return null;
        }
        MemberReference retModuleMemberReference;
        IName name = this.GetNameFromOffset(memberRefRow.Name);
        byte firstByte = this.PEFileReader.BlobStream.GetByteAt(memberRefRow.Signature, 0);
        IModuleGenericTypeInstance/*?*/ genericTypeInstance = parentTypeReference as IModuleGenericTypeInstance;
        IModuleSpecializedNestedTypeReference/*?*/ specializedNestedTypeReference = parentTypeReference as IModuleSpecializedNestedTypeReference;
        if (SignatureHeader.IsFieldSignature(firstByte)) {
          if (genericTypeInstance != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new GenericInstanceFieldReference(this, memberRefRowId, genericTypeInstance, name);
          } else if (specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new SpecializedNestedTypeFieldReference(this, memberRefRowId, parentTypeReference, specializedNestedTypeReference, name);
          } else {
            retModuleMemberReference = new FieldReference(this, memberRefRowId, parentTypeReference, name);
          }
        } else if (SignatureHeader.IsMethodSignature(firstByte)) {
          if (genericTypeInstance != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new GenericInstanceMethodReference(this, memberRefRowId, genericTypeInstance, name, firstByte);
          } else if (specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore recompute every time.
            return new SpecializedNestedTypeMethodReference(this, memberRefRowId, parentTypeReference, specializedNestedTypeReference, name, firstByte);
          } else {
            retModuleMemberReference = new MethodReference(this, memberRefRowId, parentTypeReference, name, firstByte);
          }
        } else {
          //  MD Error
          return null;
        }
        this.ModuleMemberReferenceArray[memberRefRowId] = retModuleMemberReference;
      }
      MemberReference/*?*/ ret = this.ModuleMemberReferenceArray[memberRefRowId];
      return ret;
    }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:91,代码来源:PEFileToObjectModel.cs

示例8: SignatureConverter

 internal SignatureConverter(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader,
   MetadataObject metadataOwnerObject
 )
   //^ requires signatureMemoryReader.Length > 0;
 {
   this.PEFileToObjectModel = peFileToObjectModel;
   this.SignatureMemoryReader = signatureMemoryReader;
   this.MetadataOwnerObject = metadataOwnerObject;
   this.ModuleMethodReference = metadataOwnerObject as IMethodReference;
   this.ModuleMemberReference = metadataOwnerObject as ITypeMemberReference;
   TypeMember/*?*/ moduleTypeMember = metadataOwnerObject as TypeMember;
   if (moduleTypeMember != null) {
     this.ModuleGenericType = moduleTypeMember.ContainingTypeDefinition as TypeBase;
     this.ModuleGenericMethod = moduleTypeMember as GenericMethod;
     return;
   }
   var moduleGenericType = metadataOwnerObject as TypeBase;
   if (moduleGenericType != null) {
     this.ModuleGenericType = moduleGenericType;
     return;
   }
   GenericTypeParameter/*?*/ genericTypeParam = metadataOwnerObject as GenericTypeParameter;
   if (genericTypeParam != null) {
     this.ModuleGenericType = genericTypeParam.OwningGenericType;
     return;
   }
   GenericMethodParameter/*?*/ genericMethodParam = metadataOwnerObject as GenericMethodParameter;
   if (genericMethodParam != null) {
     this.ModuleGenericType = genericMethodParam.OwningGenericMethod.ContainingTypeDefinition as TypeBase;
     this.ModuleGenericMethod = genericMethodParam.OwningGenericMethod;
     return;
   }
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:35,代码来源:PEFileToObjectModel.cs

示例9: GetModuleMemberReferenceAtRowWorker

    //^ invariant this.PEFileReader.MethodSpecTable.NumberOfRows >= 1 ==> this.MethodSpecHashtable != null;

    internal ITypeMemberReference/*?*/ GetModuleMemberReferenceAtRowWorker(
      MetadataObject owningObject,
      uint memberRefRowId
    ) {
      if (memberRefRowId == 0 || memberRefRowId > this.PEFileReader.MemberRefTable.NumberOfRows) {
        return null;
      }
      if (this.ModuleMemberReferenceArray[memberRefRowId] == null) {
        MemberRefRow memberRefRow = this.PEFileReader.MemberRefTable[memberRefRowId];
        uint classTokenType = memberRefRow.Class & TokenTypeIds.TokenTypeMask;
        uint classRowId = memberRefRow.Class & TokenTypeIds.RIDMask;
        ITypeReference/*?*/ parentTypeReference = null;
        switch (classTokenType) {
          case TokenTypeIds.TypeDef:
            parentTypeReference = this.GetTypeDefinitionAtRow(classRowId);
            break;
          case TokenTypeIds.TypeRef:
            parentTypeReference = this.GetTypeRefReferenceAtRow(classRowId);
            break;
          case TokenTypeIds.TypeSpec:
            parentTypeReference = this.GetTypeSpecReferenceAtRow(owningObject, classRowId).UnderlyingModuleTypeReference;
            break;
          case TokenTypeIds.MethodDef: {
              var/*?*/ methodDef = this.GetMethodDefAtRow(classRowId);
              if (methodDef == null) {
                //  Error...
                return null;
              }
              parentTypeReference = methodDef.ContainingType;
              break;
            }
          case TokenTypeIds.ModuleRef: {
              ModuleReference/*?*/ modRef = this.GetModuleReferenceAt(classRowId);
              if (modRef == null) {
                //  MDError
                return null;
              }
              var module = this.ResolveModuleRefReference(modRef) as Module;
              if (module == null) {
                //TODO: MDError...
                return null;
              }
              PEFileToObjectModel modulePEFileToObjectModel = module.PEFileToObjectModel;
              parentTypeReference = modulePEFileToObjectModel._Module_;
              break;
            }
          default: {
              //  MDError...
              return null;
            }
        }
        if (parentTypeReference == null) {
          //  Error...
          return null;
        }
        MemberReference retModuleMemberReference;
        IName name = this.GetNameFromOffset(memberRefRow.Name);
        byte firstByte = this.PEFileReader.BlobStream.GetByteAt(memberRefRow.Signature, 0);
        var genericTypeInstance = parentTypeReference as IGenericTypeInstanceReference;
        var specializedNestedTypeReference = parentTypeReference as ISpecializedNestedTypeReference;
        if (SignatureHeader.IsFieldSignature(firstByte)) {
          if (genericTypeInstance != null || specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore special caching is required
            FieldReference unspecializedFieldReference = this.UnspecializedMemberReferenceArray[memberRefRowId] as FieldReference;
            if (unspecializedFieldReference == null) {
              unspecializedFieldReference = new FieldReference(this, memberRefRowId, TypeCache.Unspecialize(parentTypeReference), name);
              this.UnspecializedMemberReferenceArray[memberRefRowId] = unspecializedFieldReference;
            }
            uint key1 = parentTypeReference.InternedKey;
            uint key2 = unspecializedFieldReference.InternedKey;
            var specializedField = this.SpecializedFieldHashtable.Find(key1, key2);
            if (specializedField == null) {
              specializedField = new SpecializedFieldReference(parentTypeReference, unspecializedFieldReference, this.InternFactory);
              this.SpecializedFieldHashtable.Add(key1, key2, specializedField);
            }
            return specializedField;
          } else {
            retModuleMemberReference = new FieldReference(this, memberRefRowId, parentTypeReference, name);
          }
        } else if (SignatureHeader.IsMethodSignature(firstByte)) {
          if (genericTypeInstance != null || specializedNestedTypeReference != null) {
            //The same memberRef token can be shared by distinct instance references, therefore special caching is required
            MethodReference unspecializedMethodReference = this.UnspecializedMemberReferenceArray[memberRefRowId] as MethodReference;
            if (unspecializedMethodReference == null) {
              unspecializedMethodReference = new MethodReference(this, memberRefRowId, TypeCache.Unspecialize(parentTypeReference), name, firstByte);
              this.UnspecializedMemberReferenceArray[memberRefRowId] = unspecializedMethodReference;
            }
            uint key1 = parentTypeReference.InternedKey;
            uint key2 = unspecializedMethodReference.InternedKey;
            var specializedMethod = this.SpecializedMethodHashtable.Find(key1, key2);
            if (specializedMethod == null) {
              specializedMethod = new SpecializedMethodReference(parentTypeReference, unspecializedMethodReference, this.InternFactory);
              this.SpecializedMethodHashtable.Add(key1, key2, specializedMethod);
            }
            return specializedMethod;
          } else {
            retModuleMemberReference = new MethodReference(this, memberRefRowId, parentTypeReference, name, firstByte);
          }
//.........这里部分代码省略.........
开发者ID:Biegal,项目名称:Afterthought,代码行数:101,代码来源:PEFileToObjectModel.cs

示例10: GetMarshallingInformation

 internal IMarshallingInformation GetMarshallingInformation(
   MetadataObject metadataObject
 ) {
   uint fieldMarshalRowId = this.PEFileReader.FieldMarshalTable.GetFieldMarshalRowId(metadataObject.TokenValue);
   if (fieldMarshalRowId == 0)
     return Dummy.MarshallingInformation;
   FieldMarshalRow fieldMarshalRow = this.PEFileReader.FieldMarshalTable[fieldMarshalRowId];
   MemoryBlock fieldMarshalMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(fieldMarshalRow.NativeType);
   MemoryReader memoryReader = new MemoryReader(fieldMarshalMemoryBlock);
   System.Runtime.InteropServices.UnmanagedType unmanagedType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
   if (memoryReader.NotEndOfBytes) {
     if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       System.Runtime.InteropServices.UnmanagedType elementType = System.Runtime.InteropServices.UnmanagedType.AsAny;
       if (memoryReader.NotEndOfBytes)
         elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       return new ByValArrayMarshallingInformation(elementType, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) {
       string marshallerName;
       string marshallerArgument;
       memoryReader.ReadInt16(); //  Deliberate Skip...
       int byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerName = string.Empty;
       else
         marshallerName = memoryReader.ReadUTF8WithSize(byteLen);
       ITypeReference/*?*/ marshaller = this.GetSerializedTypeNameAsTypeReference(marshallerName);
       if (marshaller == null) marshaller = Dummy.TypeReference;
       byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerArgument = string.Empty;
       else
         marshallerArgument = memoryReader.ReadUTF8WithSize(byteLen);
       return new CustomMarshallingInformation(marshaller, marshallerArgument);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) {
       System.Runtime.InteropServices.UnmanagedType elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       int paramIndex = -1;
       uint flag = 0;
       uint numElements = 0;
       if (memoryReader.NotEndOfBytes)
         paramIndex = (int)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes)
         numElements = (uint)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes) {
         flag = (uint)memoryReader.ReadCompressedUInt32();
         if (flag == 0) {
           //TODO: check that paramIndex is 0
           paramIndex = -1; //paramIndex is just a place holder so that numElements can be present
         }
       }
       return new LPArrayMarshallingInformation(elementType, paramIndex, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray) {
       System.Runtime.InteropServices.VarEnum elementType = (System.Runtime.InteropServices.VarEnum)memoryReader.ReadByte();
       string subType = string.Empty;
       if (memoryReader.NotEndOfBytes) {
         int byteLen = memoryReader.ReadCompressedUInt32();
         if (byteLen > 0)
           subType = memoryReader.ReadUTF8WithSize(byteLen);
       }
       ITypeReference/*?*/ subTypeRef = this.GetSerializedTypeNameAsTypeReference(subType);
       if (subTypeRef == null) subTypeRef = Dummy.TypeReference;
       return new SafeArrayMarshallingInformation(elementType, subTypeRef);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValTStr) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       return new ByValTStrMarshallingInformation(numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface) {
       uint iidParameterIndex = (uint)memoryReader.ReadCompressedUInt32();
       return new IidParameterIndexMarshallingInformation(iidParameterIndex);
     } else {
       //TODO: error blob should not have extra info unless one of the above types.
     }
   }
   return new SimpleMarshallingInformation(unmanagedType);
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:74,代码来源:PEFileToObjectModel.cs

示例11: GetDefaultValue

 internal IMetadataConstant GetDefaultValue(
   MetadataObject metadataObject
 ) {
   uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue);
   if (constRowId == 0)
     return Dummy.Constant;
   ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId];
   MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value);
   MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock);
   switch (constRow.Type) {
     case ElementType.Boolean: {
         byte val = memoryReader.ReadByte();
         return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0);
       }
     case ElementType.Char:
       return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar());
     case ElementType.Int8:
       return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte());
     case ElementType.Int16:
       return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16());
     case ElementType.Int32:
       return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32());
     case ElementType.Int64:
       return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64());
     case ElementType.UInt8:
       return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte());
     case ElementType.UInt16:
       return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16());
     case ElementType.UInt32:
       return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32());
     case ElementType.UInt64:
       return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64());
     case ElementType.Single:
       return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle());
     case ElementType.Double:
       return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble());
     case ElementType.String: {
         int byteLen = memoryReader.Length;
         string/*?*/ value;
         if (byteLen == -1) {
           value = null;
         } else if (byteLen == 0) {
           value = string.Empty;
         } else {
           value = memoryReader.ReadUTF16WithSize(byteLen);
         }
         return new ConstantExpression(this.PlatformType.SystemString, value);
       }
     case ElementType.Class:
       return new ConstantExpression(this.PlatformType.SystemObject, null);
   }
   //  MDError...
   return Dummy.Constant;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:54,代码来源:PEFileToObjectModel.cs

示例12: GetTypeReferenceForToken

 internal ITypeReference/*?*/ GetTypeReferenceForToken(
   MetadataObject owningObject,
   uint token,
   bool mustBeStruct
 ) {
   uint tokenType = token & TokenTypeIds.TokenTypeMask;
   uint rowId = token & TokenTypeIds.RIDMask;
   switch (tokenType) {
     case TokenTypeIds.TypeDef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeDefTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeDefinitionAtRow(rowId);
       }
     case TokenTypeIds.TypeRef: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeRefTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeRefReferenceAtRow(rowId, mustBeStruct);
       }
     case TokenTypeIds.TypeSpec: {
         if (rowId == 0 || rowId > this.PEFileReader.TypeSpecTable.NumberOfRows) {
           //  handle Error
         }
         return this.GetTypeSpecReferenceAtRow(owningObject, rowId).UnderlyingModuleTypeReference;
       }
   }
   return null;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:29,代码来源:PEFileToObjectModel.cs

示例13: GetTypeSpecReferenceAtRow

 internal TypeSpecReference/*?*/ GetTypeSpecReferenceAtRow(
   MetadataObject owningObject,
   uint typeSpecRowId
 )
   //^ requires this.PEFileReader.TypeSpecTable.NumberOfRows >= 1;
   //^ requires typeSpecRowId >= 1 && typeSpecRowId <= this.PEFileReader.TypeSpecTable.NumberOfRows;
 {
   if (typeSpecRowId > this.PEFileReader.TypeSpecTable.NumberOfRows || typeSpecRowId == 0) {
     return null;
   }
   uint ownerId = owningObject.TokenValue;
   //^ assert this.ModuleTypeSpecHashtable != null;
   TypeSpecReference/*?*/ typeSpecReference = this.ModuleTypeSpecHashtable.Find(ownerId, typeSpecRowId);
   if (typeSpecReference == null) {
     lock (GlobalLock.LockingObject) {
       typeSpecReference = this.ModuleTypeSpecHashtable.Find(ownerId, typeSpecRowId);
       if (typeSpecReference == null) {
         typeSpecReference = new TypeSpecReference(this, typeSpecRowId, owningObject);
       }
       this.ModuleTypeSpecHashtable.Add(ownerId, typeSpecRowId, typeSpecReference);
     }
   }
   return typeSpecReference;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:24,代码来源:PEFileToObjectModel.cs

示例14: GetSecurityAttributeInfo

 internal void GetSecurityAttributeInfo(
   MetadataObject metadataObject,
   out uint securityAttributeRowIdStart,
   out uint securityAttributeRowIdEnd
 ) {
   securityAttributeRowIdStart = 0;
   securityAttributeRowIdEnd = 0;
   if (metadataObject.TokenValue == 0xFFFFFFFF)
     return;
   uint securityAttributeCount;
   securityAttributeRowIdStart = this.PEFileReader.DeclSecurityTable.FindSecurityAttributesForToken(metadataObject.TokenValue, out securityAttributeCount);
   securityAttributeRowIdEnd = securityAttributeRowIdStart + securityAttributeCount;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:13,代码来源:PEFileToObjectModel.cs

示例15: GetSecurityAttributeAtRow

 internal ISecurityAttribute GetSecurityAttributeAtRow(
   MetadataObject owningObject,
   uint securityAttributeRowId
 ) {
   if (securityAttributeRowId >= this.DeclSecurityArray.Length) {
     //  MD Error
     return Dummy.SecurityAttribute;
   }
   if (this.DeclSecurityArray[securityAttributeRowId] == null) {
     lock (GlobalLock.LockingObject) {
       if (this.DeclSecurityArray[securityAttributeRowId] == null) {
         DeclSecurityRow declSecurity = this.PEFileReader.DeclSecurityTable[securityAttributeRowId];
         if (declSecurity.Parent == owningObject.TokenValue) {
           this.DeclSecurityArray[securityAttributeRowId] = new SecurityAttribute(this, securityAttributeRowId, (SecurityAction)declSecurity.ActionFlags);
         } else {
           //  MD Error
           this.DeclSecurityArray[securityAttributeRowId] = Dummy.SecurityAttribute;
         }
       }
     }
   }
   ISecurityAttribute/*?*/ ret = this.DeclSecurityArray[securityAttributeRowId];
   //^ assert ret != null;
   return ret;
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:25,代码来源:PEFileToObjectModel.cs


注:本文中的MetadataObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。