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


C# MetadataReader.GetBlobContent方法代码示例

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


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

示例1: CreateRuntimeAssemblyNameFromMetadata

        private static RuntimeAssemblyName CreateRuntimeAssemblyNameFromMetadata(
            MetadataReader reader,
            StringHandle name,
            Version version,
            StringHandle culture,
            BlobHandle publicKeyOrToken,
            AssemblyFlags assemblyFlags)
        {
            AssemblyNameFlags assemblyNameFlags = AssemblyNameFlags.None;
            if (0 != (assemblyFlags & AssemblyFlags.PublicKey))
                assemblyNameFlags |= AssemblyNameFlags.PublicKey;
            if (0 != (assemblyFlags & AssemblyFlags.Retargetable))
                assemblyNameFlags |= AssemblyNameFlags.Retargetable;
            int contentType = ((int)assemblyFlags) & 0x00000E00;
            assemblyNameFlags |= (AssemblyNameFlags)contentType;

            return new RuntimeAssemblyName(
                name.GetString(reader),
                version,
                culture.GetString(reader),
                assemblyNameFlags,
                reader.GetBlobContent(publicKeyOrToken).ToArray()
                );
        }
开发者ID:nattress,项目名称:corert,代码行数:24,代码来源:MetadataReaderExtensions.Ecma.cs

示例2: ReadAssemblyIdentity

        private static AssemblyIdentity ReadAssemblyIdentity(SystemMetadataReader metadataReader)
        {
            var assemblyDefinition = metadataReader.GetAssemblyDefinition();
            string name = metadataReader.GetString(assemblyDefinition.Name);
            Version version = assemblyDefinition.Version;
            string cultureName = metadataReader.GetString(assemblyDefinition.Culture);
            ImmutableArray<byte> publicKeyOrToken = metadataReader.GetBlobContent(assemblyDefinition.PublicKey);
            AssemblyFlags flags = assemblyDefinition.Flags;
            bool hasPublicKey = (flags & AssemblyFlags.PublicKey) != 0;

            return new AssemblyIdentity(name, version, cultureName, publicKeyOrToken, hasPublicKey: hasPublicKey);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:AnalyzerDependencyChecker.cs

示例3: ReadReferences

        private static ImmutableArray<AssemblyIdentity> ReadReferences(SystemMetadataReader metadataReader)
        {
            var builder = ImmutableArray.CreateBuilder<AssemblyIdentity>();
            foreach (var referenceHandle in metadataReader.AssemblyReferences)
            {
                var reference = metadataReader.GetAssemblyReference(referenceHandle);

                string refname = metadataReader.GetString(reference.Name);
                Version refversion = reference.Version;
                string refcultureName = metadataReader.GetString(reference.Culture);
                ImmutableArray<byte> refpublicKeyOrToken = metadataReader.GetBlobContent(reference.PublicKeyOrToken);
                AssemblyFlags refflags = reference.Flags;
                bool refhasPublicKey = (refflags & AssemblyFlags.PublicKey) != 0;

                builder.Add(new AssemblyIdentity(refname, refversion, refcultureName, refpublicKeyOrToken, hasPublicKey: refhasPublicKey));
            }

            return builder.ToImmutable();
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:19,代码来源:AnalyzerDependencyChecker.cs

示例4: CheckAssemblyProperties

        private void CheckAssemblyProperties(MetadataReader referenceMetadata, MetadataReader newMetadata)
        {
            AssemblyDefinition referenceAssemblyDefinition = referenceMetadata.GetAssemblyDefinition();
            AssemblyDefinition newAssemblyDefinition = newMetadata.GetAssemblyDefinition();

            string referenceName = referenceMetadata.GetString(referenceAssemblyDefinition.Name);
            string newName = newMetadata.GetString(newAssemblyDefinition.Name);
            if (!string.Equals(referenceName, newName, StringComparison.Ordinal))
                _logger.Report(AssemblyNameMustNotBeChanged.CreateMessage());

            string referenceCulture = referenceMetadata.GetString(referenceAssemblyDefinition.Culture);
            string newCulture = referenceMetadata.GetString(newAssemblyDefinition.Culture);
            if (!string.Equals(referenceCulture, newCulture, StringComparison.Ordinal))
                throw new NotImplementedException("Assembly culture changed.");

            if (!referenceAssemblyDefinition.PublicKey.IsNil)
            {
                // adding a public key is supported, but removing or changing it is not.
                var referencePublicKey = referenceMetadata.GetBlobContent(referenceAssemblyDefinition.PublicKey);
                var newPublicKey = newMetadata.GetBlobContent(newAssemblyDefinition.PublicKey);
                if (!referencePublicKey.SequenceEqual(newPublicKey))
                    _logger.Report(PublicKeyMustNotBeChanged.CreateMessage());
            }
        }
开发者ID:modulexcite,项目名称:dotnet-compatibility,代码行数:24,代码来源:Analyzer.cs


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