本文整理汇总了C#中TypeRef.EnterConstructor方法的典型用法代码示例。如果您正苦于以下问题:C# TypeRef.EnterConstructor方法的具体用法?C# TypeRef.EnterConstructor怎么用?C# TypeRef.EnterConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeRef
的用法示例。
在下文中一共展示了TypeRef.EnterConstructor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeSigFromTypeRef
private PE.TypeSig TypeSigFromTypeRef(DllSaveContext ctxt, TypeRef typeRef)
{
if (typeRef.Equals(rootEnv.Global.TypedReferenceRef))
return new PE.PrimitiveTypeSig { PrimitiveType = PE.PrimitiveType.TypedRef };
else
{
var tyconEnv = typeRef.EnterConstructor(rootEnv);
switch (tyconEnv.Type.Flavor)
{
case TypeDefFlavor.Pointer:
{
var p = (PointerTypeDef)tyconEnv.Type;
switch (p.PointerFlavor)
{
case PointerFlavor.Unmanaged:
return new PE.UnmanagedPointerTypeSig { ElementType = TypeWithCustomModsFromTypeRef(ctxt, typeRef.Arguments[0]) };
case PointerFlavor.Managed:
return new PE.ManagedPointerTypeSig { ElementType = TypeSigFromTypeRef(ctxt, typeRef.Arguments[0]) };
default:
throw new ArgumentOutOfRangeException();
}
}
case TypeDefFlavor.CodePointer:
{
var p = (CodePointerTypeDef)tyconEnv.Type;
switch (p.CodePointerFlavor)
{
case CodePointerFlavor.Function:
throw new NotImplementedException();
case CodePointerFlavor.Action:
throw new NotImplementedException();
default:
throw new ArgumentOutOfRangeException();
}
break;
}
case TypeDefFlavor.Array:
return new PE.ArrayTypeSig { ElementType = TypeWithCustomModsFromTypeRef(ctxt, typeRef.Arguments[0]) };
case TypeDefFlavor.MultiDimArray:
{
var a = (MultiDimArrayTypeDef)tyconEnv.Type;
return new PE.MultiDimArrayTypeSig
{
ElementType = TypeSigFromTypeRef(ctxt, typeRef.Arguments[0]),
Rank = a.Rank,
LoBounds = a.Bounds.LoBounds(),
Sizes = a.Bounds.Sizes()
};
}
case TypeDefFlavor.Box:
throw new InvalidOperationException("unexpected box type");
case TypeDefFlavor.Null:
throw new InvalidOperationException("unexpected null type");
case TypeDefFlavor.Parameter:
{
var p = (ParameterTypeDef)tyconEnv.Type;
switch (p.ParameterFlavor)
{
case ParameterFlavor.Type:
return new PE.TypeParameterTypeSig { Index = p.Index };
case ParameterFlavor.Method:
return new PE.MethodParameterTypeSig { Index = p.Index };
default:
throw new ArgumentOutOfRangeException();
}
}
case TypeDefFlavor.Handle:
case TypeDefFlavor.Nullable:
case TypeDefFlavor.Enum:
case TypeDefFlavor.Struct:
{
var applicand = new PE.TypeDefOrRefSig
{
IsValueType = true,
TypeDefOrRef = { Value = TypeDefOrRefRowFromQualifiedTypeName(ctxt, typeRef.QualifiedTypeName) }
};
if (typeRef.Arguments.Count > 0)
return new PE.ApplicationTypeSig
{
Applicand = applicand,
Arguments = typeRef.Arguments.Select(t => TypeSigFromTypeRef(ctxt, t)).ToSeq()
};
else
return applicand;
}
case TypeDefFlavor.Void:
return new PE.PrimitiveTypeSig { PrimitiveType = PE.PrimitiveType.Void };
case TypeDefFlavor.Number:
{
var n = (NumberTypeDef)tyconEnv.Type;
var p = default(PE.PrimitiveType);
switch (n.NumberFlavor)
{
case NumberFlavor.Int8:
p = PE.PrimitiveType.Int8;
break;
case NumberFlavor.Int16:
p = PE.PrimitiveType.Int16;
break;
//.........这里部分代码省略.........