本文整理汇总了C#中TypeDefinitionHandle类的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinitionHandle类的具体用法?C# TypeDefinitionHandle怎么用?C# TypeDefinitionHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDefinitionHandle类属于命名空间,在下文中一共展示了TypeDefinitionHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: GetWellKnownTypeDefinitionTreatment
private TypeDefTreatment GetWellKnownTypeDefinitionTreatment(TypeDefinitionHandle typeDef)
{
InitializeProjectedTypes();
StringHandle name = TypeDefTable.GetName(typeDef);
int index = StringStream.BinarySearchRaw(s_projectedTypeNames, name);
if (index < 0)
{
return TypeDefTreatment.None;
}
StringHandle namespaceName = TypeDefTable.GetNamespace(typeDef);
if (StringStream.EqualsRaw(namespaceName, StringStream.GetVirtualValue(s_projectionInfos[index].ClrNamespace)))
{
return s_projectionInfos[index].Treatment;
}
// TODO: we can avoid this comparison if info.DotNetNamespace == info.WinRtNamespace
if (StringStream.EqualsRaw(namespaceName, s_projectionInfos[index].WinRTNamespace))
{
return s_projectionInfos[index].Treatment | TypeDefTreatment.MarkInternalFlag;
}
return TypeDefTreatment.None;
}
示例3: GetTypeLayout
internal static ClassLayoutRow GetTypeLayout(this MetadataReader reader, TypeDefinitionHandle typeDef)
{
uint rowId = reader.ClassLayoutTable.FindRow(typeDef);
if (rowId == 0)
{
return default(ClassLayoutRow);
}
return GetTypeLayout(reader, rowId);
}
示例4: EcmaType
internal EcmaType(EcmaModule module, TypeDefinitionHandle handle)
{
_module = module;
_handle = handle;
_typeDefinition = module.MetadataReader.GetTypeDefinition(handle);
_baseType = this; // Not yet initialized flag
#if DEBUG
// Initialize name eagerly in debug builds for convenience
this.ToString();
#endif
}
示例5: RuntimeInspectionOnlyNamedType
protected RuntimeInspectionOnlyNamedType(MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle)
: base()
{
#if DEBUG
if (!(this.InternalViolatesTypeIdentityRules))
{
RuntimeTypeHandle runtimeTypeHandle;
if (ReflectionCoreExecution.ExecutionEnvironment.TryGetNamedTypeForMetadata(reader, typeDefinitionHandle, out runtimeTypeHandle))
Debug.Assert(false, "Type identity violation: You must use a RuntimeEENamedType to represent this type as RH has generated an EEType for it.");
}
#endif
_reader = reader;
_typeDefinitionHandle = typeDefinitionHandle;
_typeDefinition = _typeDefinitionHandle.GetTypeDefinition(_reader);
}
示例6: ShouldImportNestedType
/// <summary>
/// Returns true if the nested type should be imported.
/// </summary>
public static bool ShouldImportNestedType(this PEModule module, TypeDefinitionHandle typeDef)
{
// Currently, it appears that we must import ALL types, even private ones,
// in order to maintain language semantics. This is because a class may implement
// private interfaces, and we use the interfaces (even if inaccessible) to determine
// conversions. For example:
//
// public class A: IEnumerable<A.X>
// {
// private class X: ICloneable {}
// }
//
// Code compiling against A can convert A to IEnumerable<ICloneable>. Knowing this requires
// importing the type A.X.
return true;
}
示例7: AddEventMap
public void AddEventMap(TypeDefinitionHandle declaringType, EventDefinitionHandle eventList)
{
_eventMapTable.Add(new EventMapRow
{
Parent = (uint)MetadataTokens.GetRowNumber(declaringType),
EventList = (uint)MetadataTokens.GetRowNumber(eventList)
});
}
示例8: AddPropertyMap
public void AddPropertyMap(TypeDefinitionHandle declaringType, PropertyDefinitionHandle propertyList)
{
_propertyMapTable.Add(new PropertyMapRow
{
Parent = (uint)MetadataTokens.GetRowNumber(declaringType),
PropertyList = (uint)MetadataTokens.GetRowNumber(propertyList)
});
}
示例9: IsClrImplementationType
private bool IsClrImplementationType(TypeDefinitionHandle typeDef)
{
var attrs = TypeDefTable.GetFlags(typeDef);
if ((attrs & (TypeAttributes.VisibilityMask | TypeAttributes.SpecialName)) != TypeAttributes.SpecialName)
{
return false;
}
return StringStream.StartsWithRaw(TypeDefTable.GetName(typeDef), ClrPrefix);
}
示例10: GetFieldRange
internal void GetFieldRange(TypeDefinitionHandle typeDef, out int firstFieldRowId, out int lastFieldRowId)
{
int typeDefRowId = typeDef.RowId;
firstFieldRowId = this.TypeDefTable.GetFieldStart(typeDefRowId);
if (firstFieldRowId == 0)
{
firstFieldRowId = 1;
lastFieldRowId = 0;
}
else if (typeDefRowId == this.TypeDefTable.NumberOfRows)
{
lastFieldRowId = (this.UseFieldPtrTable) ? this.FieldPtrTable.NumberOfRows : this.FieldTable.NumberOfRows;
}
else
{
lastFieldRowId = this.TypeDefTable.GetFieldStart(typeDefRowId + 1) - 1;
}
}
示例11: ResolveTypeDefinition
//
// Main routine to resolve a typeDefinition.
//
internal static RuntimeType ResolveTypeDefinition(this ReflectionDomain reflectionDomain, MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle)
{
return RuntimeTypeUnifierEx.GetNamedType(reader, typeDefinitionHandle);
}
示例12: GetInterfaceImplRange
internal void GetInterfaceImplRange(
TypeDefinitionHandle typeDef,
out int firstImplRowId,
out int lastImplRowId)
{
int typeDefRid = typeDef.RowId;
int startRowNumber, endRowNumber;
this.Block.BinarySearchReferenceRange(
this.NumberOfRows,
this.RowSize,
_ClassOffset,
(uint)typeDefRid,
_IsTypeDefTableRowRefSizeSmall,
out startRowNumber,
out endRowNumber);
if (startRowNumber == -1)
{
firstImplRowId = 1;
lastImplRowId = 0;
}
else
{
firstImplRowId = startRowNumber + 1;
lastImplRowId = endRowNumber + 1;
}
}
示例13: FindGenericParametersForType
internal GenericParameterHandleCollection FindGenericParametersForType(TypeDefinitionHandle typeDef)
{
ushort count = 0;
uint searchCodedTag = TypeOrMethodDefTag.ConvertTypeDefRowIdToTag(typeDef);
int startRid = (int)this.BinarySearchTag(searchCodedTag, ref count);
return new GenericParameterHandleCollection(startRid, count);
}
示例14: FindEnclosingType
internal TypeDefinitionHandle FindEnclosingType(TypeDefinitionHandle nestedTypeDef)
{
int rowNumber =
this.Block.BinarySearchReference(
this.NumberOfRows,
this.RowSize,
_NestedClassOffset,
(uint)nestedTypeDef.RowId,
_IsTypeDefTableRowRefSizeSmall);
if (rowNumber == -1)
{
return default(TypeDefinitionHandle);
}
return TypeDefinitionHandle.FromRowId(this.Block.PeekReference(rowNumber * this.RowSize + _EnclosingClassOffset, _IsTypeDefTableRowRefSizeSmall));
}
示例15: GetExtends
internal EntityHandle GetExtends(TypeDefinitionHandle handle)
{
int rowOffset = (handle.RowId - 1) * this.RowSize;
return TypeDefOrRefTag.ConvertToHandle(this.Block.PeekTaggedReference(rowOffset + _ExtendsOffset, _IsTypeDefOrRefRefSizeSmall));
}