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


C# Metadata.MetadataReader类代码示例

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


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

示例1: AssemblyCatalogInfo

        //private bool hasInheritedExports = false;
        //private readonly Dictionary<Handle, bool> inheritedExportTypes = new Dictionary<Handle, bool>();
        //private readonly HashSet<string> inheritedExportTypesByName = new HashSet<string>();

        public AssemblyCatalogInfo(Discovery discovery, MetadataReader metadataReader, string assemblyFilePath)
        {
            Debug.WriteLine("AssemblyCatalogInfo: " + assemblyFilePath);
            this.discovery = discovery;
            this.metadataReader = metadataReader;
            this.assemblyFilePath = assemblyFilePath;
        }
开发者ID:szKarlen,项目名称:MEFMetadata,代码行数:11,代码来源:AssemblyCatalogInfo.cs

示例2: PdbToXmlConverter

 private PdbToXmlConverter(XmlWriter writer, TempPdbReader pdbReader, MetadataReader metadataReader, PdbToXmlOptions options)
 {
     this.pdbReader = pdbReader;
     this.metadataReader = metadataReader;
     this.writer = writer;
     this.options = options;
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:7,代码来源:PdbToXml.cs

示例3: DocumentMap

        public DocumentMap(MetadataReader reader)
        {
            _reader = reader;

            // group ignoring case, we will match the case within the group
            _map = GetDocumentsByFileName(reader).GroupBy(StringComparer.OrdinalIgnoreCase);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:DocumentMap.cs

示例4: PdbToXmlConverter

 private PdbToXmlConverter(XmlWriter writer, ISymUnmanagedReader symReader, MetadataReader metadataReader, PdbToXmlOptions options)
 {
     _symReader = symReader;
     _metadataReader = metadataReader;
     _writer = writer;
     _options = options;
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:7,代码来源:PdbToXml.cs

示例5: ToXml

        public unsafe static void ToXml(TextWriter xmlWriter, Stream pdbStream, Stream peStream, PdbToXmlOptions options = PdbToXmlOptions.Default, string methodName = null)
        {
            IEnumerable<MethodHandle> methodHandles;
            var headers = new PEHeaders(peStream);
            byte[] metadata = new byte[headers.MetadataSize];
            peStream.Seek(headers.MetadataStartOffset, SeekOrigin.Begin);
            peStream.Read(metadata, 0, headers.MetadataSize);

            fixed (byte* metadataPtr = metadata)
            {
                var metadataReader = new MetadataReader((IntPtr)metadataPtr, metadata.Length);

                if (string.IsNullOrEmpty(methodName))
                {
                    methodHandles = metadataReader.MethodDefinitions;
                }
                else
                {
                    methodHandles = metadataReader.MethodDefinitions.
                        Where(methodHandle => GetQualifiedMethodName(metadataReader, methodHandle) == methodName);
                }

                ToXml(xmlWriter, pdbStream, metadataReader, options, methodHandles);
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:25,代码来源:PdbToXml.cs

示例6: GetAnonymousTypeMap

 private static IReadOnlyDictionary<AnonymousTypeKey, AnonymousTypeValue> GetAnonymousTypeMap(
     MetadataReader reader,
     Symbols.Metadata.PE.MetadataDecoder metadataDecoder)
 {
     var result = new Dictionary<AnonymousTypeKey, AnonymousTypeValue>();
     foreach (var handle in reader.TypeDefinitions)
     {
         var def = reader.GetTypeDefinition(handle);
         if (!def.Namespace.IsNil)
         {
             continue;
         }
         if (!reader.StringStartsWith(def.Name, GeneratedNames.AnonymousNamePrefix))
         {
             continue;
         }
         var metadataName = reader.GetString(def.Name);
         short arity;
         var name = MetadataHelpers.InferTypeArityAndUnmangleMetadataName(metadataName, out arity);
         int index;
         if (GeneratedNames.TryParseAnonymousTypeTemplateName(name, out index))
         {
             var builder = ArrayBuilder<string>.GetInstance();
             if (TryGetAnonymousTypeKey(reader, def, builder))
             {
                 var type = (NamedTypeSymbol)metadataDecoder.GetTypeOfToken(handle);
                 var key = new AnonymousTypeKey(builder.ToImmutable());
                 var value = new AnonymousTypeValue(name, index, type);
                 result.Add(key, value);
             }
             builder.Free();
         }
     }
     return result;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:35,代码来源:PEDeltaAssemblyBuilder.cs

示例7: PE

        public PE(string fileName)
        {
            FileName = Path.GetFullPath(fileName);
            Uri = new Uri(FileName);
            IsPEFile = false;
            try
            {
                _fs = File.OpenRead(FileName);

                byte byteRead = (byte)_fs.ReadByte();
                if (byteRead != 'M') { return; }

                byteRead = (byte)_fs.ReadByte();
                if (byteRead != 'Z') { return; }
                _fs.Seek(0, SeekOrigin.Begin);

                _peReader = new PEReader(_fs);
                PEHeaders = _peReader.PEHeaders;
                IsPEFile = true;
            }
            catch (IOException e) { LoadException = e; }
            catch (BadImageFormatException e) { LoadException = e; }
            catch (UnauthorizedAccessException e) { LoadException = e; }

            if (IsPEFile)
            {
                m_pImage = new SafePointer(_peReader.GetEntireImage().GetContent().ToBuilder().ToArray());

                if (IsManaged)
                {
                    _metadataReader = _peReader.GetMetadataReader();
                }
            }
        }
开发者ID:blinds52,项目名称:binskim,代码行数:34,代码来源:PE.cs

示例8: VerifyModuleMvid

        internal static void VerifyModuleMvid(int generation, MetadataReader previousReader, MetadataReader currentReader)
        {
            var previousModule = previousReader.GetModuleDefinition();
            var currentModule = currentReader.GetModuleDefinition();

            Assert.Equal(previousReader.GetGuid(previousModule.Mvid), currentReader.GetGuid(currentModule.Mvid));

            Assert.Equal(generation - 1, previousModule.Generation);
            Assert.Equal(generation, currentModule.Generation);

            if (generation == 1)
            {
                Assert.True(previousModule.GenerationId.IsNil);
                Assert.True(previousModule.BaseGenerationId.IsNil);

                Assert.False(currentModule.GenerationId.IsNil);
                Assert.True(currentModule.BaseGenerationId.IsNil);
            }
            else
            {
                Assert.False(currentModule.GenerationId.IsNil);
                Assert.False(currentModule.BaseGenerationId.IsNil);

                Assert.Equal(previousReader.GetGuid(previousModule.GenerationId), currentReader.GetGuid(currentModule.BaseGenerationId));
            }

            Assert.NotEqual(default(Guid), currentReader.GetGuid(currentModule.GenerationId));
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:28,代码来源:EncValidation.cs

示例9: PinnedMetadata

 public unsafe PinnedMetadata(ImmutableArray<byte> metadata)
 {
     _bytes = GCHandle.Alloc(metadata.DangerousGetUnderlyingArray(), GCHandleType.Pinned);
     this.Pointer = _bytes.AddrOfPinnedObject();
     this.Size = metadata.Length;
     this.Reader = new MetadataReader((byte*)this.Pointer, this.Size, MetadataReaderOptions.None, null);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:PinnedMetadata.cs

示例10: DeclarativeSecurityAttribute

        internal DeclarativeSecurityAttribute(MetadataReader reader, uint rowId)
        {
            DebugCorlib.Assert(reader != null);
            DebugCorlib.Assert(rowId != 0);

            this.reader = reader;
            this.rowId = rowId;
        }
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:8,代码来源:DeclarativeSecurityAttribute.cs

示例11: ExportedType

        internal ExportedType(MetadataReader reader, uint rowId)
        {
            DebugCorlib.Assert(reader != null);
            DebugCorlib.Assert(rowId != 0);

            this.reader = reader;
            this.rowId = rowId;
        }
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:8,代码来源:ExportedType.cs

示例12: Document

        internal Document(MetadataReader reader, DocumentHandle handle)
        {
            Debug.Assert(reader != null);
            Debug.Assert(!handle.IsNil);

            _reader = reader;
            _rowId = handle.RowId;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:Document.cs

示例13: LocalVariable

        internal LocalVariable(MetadataReader reader, LocalVariableHandle handle)
        {
            Debug.Assert(reader != null);
            Debug.Assert(!handle.IsNil);

            _reader = reader;
            _rowId = handle.RowId;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:LocalVariable.cs

示例14: ManifestResource

        internal ManifestResource(MetadataReader reader, ManifestResourceHandle handle)
        {
            DebugCorlib.Assert(reader != null);
            DebugCorlib.Assert(!handle.IsNil);

            this.reader = reader;
            this.rowId = handle.RowId;
        }
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:8,代码来源:ManifestResource.cs

示例15: EventDefinition

        internal EventDefinition(MetadataReader reader, EventDefinitionHandle handle)
        {
            DebugCorlib.Assert(reader != null);
            DebugCorlib.Assert(!handle.IsNil);

            this.reader = reader;
            this.rowId = handle.RowId;
        }
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:8,代码来源:EventDefinition.cs


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