本文整理汇总了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()
);
}
示例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);
}
示例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();
}
示例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());
}
}