本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.getPredefType方法的典型用法代码示例。如果您正苦于以下问题:C# CType.getPredefType方法的具体用法?C# CType.getPredefType怎么用?C# CType.getPredefType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.getPredefType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhichConversionIsBetter
public BetterType WhichConversionIsBetter(CType argType,
CType p1, CType p2)
{
// 7.4.2.4 Better conversion from type
//
// Given a conversion C1 that converts from a type S to a type T1 and a conversion C2
// that converts from a type S to a type T2, the better conversion of the two conversions
// is determined as follows:
//* If T1 and T2 are the same type, neither conversion is better
//* If S is T1, C1 is the better conversion.
//* If S is T2, C2 is the better conversion.
//* If an implicit conversion from T1 to T2 exists and no implicit conversion from T2 to
// T1 exists, C1 is the better conversion.
//* If an implicit conversion from T2 to T1 exists and no implicit conversion from T1 to
// T2 exists, C2 is the better conversion.
//
// [Otherwise, see table above for better integral type conversions.]
if (p1 == p2)
{
return BetterType.Same;
}
if (argType == p1)
{
return BetterType.Left;
}
if (argType == p2)
{
return BetterType.Right;
}
bool a2b = canConvert(p1, p2);
bool b2a = canConvert(p2, p1);
if (a2b && !b2a)
{
return BetterType.Left;
}
if (b2a && !a2b)
{
return BetterType.Right;
}
Debug.Assert(b2a == a2b);
if (p1.isPredefined() && p2.isPredefined() &&
p1.getPredefType() <= PredefinedType.PT_OBJECT && p2.getPredefType() <= PredefinedType.PT_OBJECT)
{
int c = s_betterConversionTable[(int)p1.getPredefType()][(int)p2.getPredefType()];
if (c == 1)
{
return BetterType.Left;
}
else if (c == 2)
{
return BetterType.Right;
}
}
return BetterType.Neither;
}