本文整理汇总了C#中TypeDefinitionHandle类的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinitionHandle类的具体用法?C# TypeDefinitionHandle怎么用?C# TypeDefinitionHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDefinitionHandle类属于命名空间,在下文中一共展示了TypeDefinitionHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:nattress,项目名称:corert,代码行数:27,代码来源:MetadataReaderHelpers.cs
示例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;
}
开发者ID:johnhhm,项目名称:corefx,代码行数:26,代码来源:MetadataReader.WinMD.cs
示例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);
}
开发者ID:svcgany1,项目名称:corefx,代码行数:10,代码来源:MetadataReaderTestHelpers.cs
示例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
}
开发者ID:noahfalk,项目名称:corert,代码行数:14,代码来源:EcmaType.cs
示例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);
}
开发者ID:huamichaelchen,项目名称:corert,代码行数:15,代码来源:RuntimeInspectionOnlyNamedType.cs
示例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;
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:20,代码来源:ModuleExtensions.cs
示例7: AddEventMap
public void AddEventMap(TypeDefinitionHandle declaringType, EventDefinitionHandle eventList)
{
_eventMapTable.Add(new EventMapRow
{
Parent = (uint)MetadataTokens.GetRowNumber(declaringType),
EventList = (uint)MetadataTokens.GetRowNumber(eventList)
});
}
开发者ID:tzetang,项目名称:corefx,代码行数:8,代码来源:MetadataBuilder.Tables.cs
示例8: AddPropertyMap
public void AddPropertyMap(TypeDefinitionHandle declaringType, PropertyDefinitionHandle propertyList)
{
_propertyMapTable.Add(new PropertyMapRow
{
Parent = (uint)MetadataTokens.GetRowNumber(declaringType),
PropertyList = (uint)MetadataTokens.GetRowNumber(propertyList)
});
}
开发者ID:tzetang,项目名称:corefx,代码行数:8,代码来源:MetadataBuilder.Tables.cs
示例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);
}
开发者ID:johnhhm,项目名称:corefx,代码行数:11,代码来源:MetadataReader.WinMD.cs
示例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;
}
}
开发者ID:SamuelEnglard,项目名称:corefx,代码行数:19,代码来源:MetadataReader.cs
示例11: ResolveTypeDefinition
//
// Main routine to resolve a typeDefinition.
//
internal static RuntimeType ResolveTypeDefinition(this ReflectionDomain reflectionDomain, MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle)
{
return RuntimeTypeUnifierEx.GetNamedType(reader, typeDefinitionHandle);
}
开发者ID:noahfalk,项目名称:corert,代码行数:7,代码来源:TypeResolver.cs
示例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;
}
}
开发者ID:jmhardison,项目名称:corefx,代码行数:28,代码来源:Tables.cs
示例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);
}
开发者ID:jmhardison,项目名称:corefx,代码行数:8,代码来源:Tables.cs
示例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));
}
开发者ID:jmhardison,项目名称:corefx,代码行数:17,代码来源:Tables.cs
示例15: GetExtends
internal EntityHandle GetExtends(TypeDefinitionHandle handle)
{
int rowOffset = (handle.RowId - 1) * this.RowSize;
return TypeDefOrRefTag.ConvertToHandle(this.Block.PeekTaggedReference(rowOffset + _ExtendsOffset, _IsTypeDefOrRefRefSizeSmall));
}
开发者ID:jmhardison,项目名称:corefx,代码行数:5,代码来源:Tables.cs
示例16: AddMethodImplementation
public void AddMethodImplementation(
TypeDefinitionHandle type,
EntityHandle methodBody,
EntityHandle methodDeclaration)
{
_methodImplTable.Add(new MethodImplRow
{
Class = (uint)MetadataTokens.GetRowNumber(type),
MethodBody = (uint)CodedIndex.ToMethodDefOrRef(methodBody),
MethodDecl = (uint)CodedIndex.ToMethodDefOrRef(methodDeclaration)
});
}
开发者ID:tzetang,项目名称:corefx,代码行数:12,代码来源:MetadataBuilder.Tables.cs
示例17: CalculateTypeDefTreatmentAndRowId
internal uint CalculateTypeDefTreatmentAndRowId(TypeDefinitionHandle handle)
{
Debug.Assert(_metadataKind != MetadataKind.Ecma335);
TypeDefTreatment treatment;
TypeAttributes flags = TypeDefTable.GetFlags(handle);
EntityHandle extends = TypeDefTable.GetExtends(handle);
if ((flags & TypeAttributes.WindowsRuntime) != 0)
{
if (_metadataKind == MetadataKind.WindowsMetadata)
{
treatment = GetWellKnownTypeDefinitionTreatment(handle);
if (treatment != TypeDefTreatment.None)
{
return TreatmentAndRowId((byte)treatment, handle.RowId);
}
// Is this an attribute?
if (extends.Kind == HandleKind.TypeReference && IsSystemAttribute((TypeReferenceHandle)extends))
{
treatment = TypeDefTreatment.NormalAttribute;
}
else
{
treatment = TypeDefTreatment.NormalNonAttribute;
}
}
else if (_metadataKind == MetadataKind.ManagedWindowsMetadata && NeedsWinRTPrefix(flags, extends))
{
// WinMDExp emits two versions of RuntimeClasses and Enums:
//
// public class Foo {} // the WinRT reference class
// internal class <CLR>Foo {} // the implementation class that we want WinRT consumers to ignore
//
// The adapter's job is to undo WinMDExp's transformations. I.e. turn the above into:
//
// internal class <WinRT>Foo {} // the WinRT reference class that we want CLR consumers to ignore
// public class Foo {} // the implementation class
//
// We only add the <WinRT> prefix here since the WinRT view is the only view that is marked WindowsRuntime
// De-mangling the CLR name is done below.
// tomat: The CLR adapter implements a back-compat quirk: Enums exported with an older WinMDExp have only one version
// not marked with tdSpecialName. These enums should *not* be mangled and flipped to private.
// We don't implement this flag since the WinMDs producted by the older WinMDExp are not used in the wild.
treatment = TypeDefTreatment.PrefixWinRTName;
}
else
{
treatment = TypeDefTreatment.None;
}
// Scan through Custom Attributes on type, looking for interesting bits. We only
// need to do this for RuntimeClasses
if ((treatment == TypeDefTreatment.PrefixWinRTName || treatment == TypeDefTreatment.NormalNonAttribute))
{
if ((flags & TypeAttributes.Interface) == 0
&& HasAttribute(handle, "Windows.UI.Xaml", "TreatAsAbstractComposableClassAttribute"))
{
treatment |= TypeDefTreatment.MarkAbstractFlag;
}
}
}
else if (_metadataKind == MetadataKind.ManagedWindowsMetadata && IsClrImplementationType(handle))
{
// <CLR> implementation classes are not marked WindowsRuntime, but still need to be modified
// by the adapter.
treatment = TypeDefTreatment.UnmangleWinRTName;
}
else
{
treatment = TypeDefTreatment.None;
}
return TreatmentAndRowId((byte)treatment, handle.RowId);
}
开发者ID:johnhhm,项目名称:corefx,代码行数:80,代码来源:MetadataReader.WinMD.cs
示例18: ValidateNestedClass
/// <summary>
/// NestedClass Table Columns:
/// NestedClass (RID to TypeDef) nestee
/// EnclosingClass (RID to TypeDef)
/// </summary>
private void ValidateNestedClass(MetadataReader reader, TypeDefinitionHandle typeDef, bool isMod = false)
{
// var expNC = new uint[] { 4, 5, 6 };
var expClasses = new int[][] { new int[] { 4, 5, 6 }, new int[] { 3, 3, 5 } };
var modClasses = new int[][] { new int[] { 4, 5, 6, 7 }, new int[] { 2, 3, 3, 5 } };
int rid = reader.NestedClassTable.FindEnclosingType(typeDef).RowId;
int[][] classes = expClasses;
if (isMod)
{
classes = modClasses;
}
Assert.Equal(rid, classes[1].Where((x, index) => classes[0][index] == typeDef.RowId).First());
}
开发者ID:nnyamhon,项目名称:corefx,代码行数:21,代码来源:MetadataReaderTests.cs
示例19: GetTypeFullNameFromTypeDef
private static String GetTypeFullNameFromTypeDef(TypeDefinitionHandle typeDefinitionHandle, MetadataReader reader, List<int> genericParameterOffsets)
{
String s = "";
TypeDefinition typeDefinition = typeDefinitionHandle.GetTypeDefinition(reader);
s = typeDefinition.Name.GetString(reader);
TypeDefinitionHandle enclosingTypeDefHandle = typeDefinition.EnclosingType;
if (!enclosingTypeDefHandle.IsNull(reader))
{
String containingTypeName = GetTypeFullNameFromTypeDef(enclosingTypeDefHandle, reader, genericParameterOffsets);
s = containingTypeName + "." + s;
}
else
{
NamespaceDefinitionHandle namespaceHandle = typeDefinition.NamespaceDefinition;
for (; ;)
{
NamespaceDefinition namespaceDefinition = namespaceHandle.GetNamespaceDefinition(reader);
String namespacePart = namespaceDefinition.Name.GetStringOrNull(reader);
if (namespacePart == null)
break; // Reached the root namespace.
s = namespacePart + "." + s;
if (namespaceDefinition.ParentScopeOrNamespace.HandleType != HandleType.NamespaceDefinition)
break; // Should have reached the root namespace first but this helper is for ToString() - better to
// return partial information than crash.
namespaceHandle = namespaceDefinition.ParentScopeOrNamespace.ToNamespaceDefinitionHandle(reader);
}
}
return ConvertBackTickNameToNameWithReducerInputFormat(s, genericParameterOffsets);
}
开发者ID:noahfalk,项目名称:corert,代码行数:31,代码来源:DiagnosticMappingTables.cs
示例20: TryGetTypeHandle
internal abstract bool TryGetTypeHandle(Cci.ITypeDefinition def, out TypeDefinitionHandle handle);
开发者ID:daking2014,项目名称:roslyn,代码行数:1,代码来源:DefinitionMap.cs
注:本文中的TypeDefinitionHandle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论