本文整理汇总了C#中MetadataReader.GetTypeReference方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader.GetTypeReference方法的具体用法?C# MetadataReader.GetTypeReference怎么用?C# MetadataReader.GetTypeReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataReader
的用法示例。
在下文中一共展示了MetadataReader.GetTypeReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTypeReferenceAcrossModules
public static bool CompareTypeReferenceAcrossModules(TypeReferenceHandle tr1, MetadataReader mr1, TypeReferenceHandle tr2, MetadataReader mr2)
{
TypeReference trData1 = mr1.GetTypeReference(tr1);
TypeReference trData2 = mr2.GetTypeReference(tr2);
if (!trData1.TypeName.StringEquals(trData2.TypeName.GetConstantStringValue(mr2).Value, mr1))
return false;
if (trData1.ParentNamespaceOrType.HandleType != trData2.ParentNamespaceOrType.HandleType)
return false;
if (trData1.ParentNamespaceOrType.HandleType == HandleType.TypeReference)
return CompareTypeReferenceAcrossModules(trData1.ParentNamespaceOrType.ToTypeReferenceHandle(mr1), mr1, trData2.ParentNamespaceOrType.ToTypeReferenceHandle(mr2), mr2);
return CompareNamespaceReferenceAcrossModules(trData1.ParentNamespaceOrType.ToNamespaceReferenceHandle(mr1), mr1, trData2.ParentNamespaceOrType.ToNamespaceReferenceHandle(mr2), mr2);
}
示例2: CompareTypeReferenceToDefinition
public static bool CompareTypeReferenceToDefinition(TypeReferenceHandle tr1, MetadataReader mr1, TypeDefinitionHandle td2, MetadataReader mr2)
{
// TODO! The correct implementation here is probably to call into the assembly binder, but that's not available due to layering.
// For now, just implement comparison, which will be equivalent in all cases until we support loading multiple copies of the same assembly
TypeReference trData1 = mr1.GetTypeReference(tr1);
TypeDefinition tdData2 = mr2.GetTypeDefinition(td2);
if (!trData1.TypeName.StringEquals(tdData2.Name.GetConstantStringValue(mr2).Value, mr1))
return false;
switch (trData1.ParentNamespaceOrType.HandleType)
{
case HandleType.TypeReference:
if (tdData2.EnclosingType.IsNull(mr2))
return false;
return CompareTypeReferenceToDefinition(trData1.ParentNamespaceOrType.ToTypeReferenceHandle(mr1), mr1, tdData2.EnclosingType, mr2);
case HandleType.NamespaceReference:
return CompareNamespaceReferenceToDefinition(trData1.ParentNamespaceOrType.ToNamespaceReferenceHandle(mr1), mr1, tdData2.NamespaceDefinition, mr2);
default:
Debug.Assert(false);
throw new BadImageFormatException();
}
}