本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType.underlyingType方法的典型用法代码示例。如果您正苦于以下问题:C# AggregateType.underlyingType方法的具体用法?C# AggregateType.underlyingType怎么用?C# AggregateType.underlyingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType
的用法示例。
在下文中一共展示了AggregateType.underlyingType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bindExplicitConversionFromDecimalToEnum
private AggCastResult bindExplicitConversionFromDecimalToEnum(AggregateType aggTypeDest)
{
Debug.Assert(_typeSrc != null);
Debug.Assert(_typeSrc.isPredefType(PredefinedType.PT_DECIMAL));
// There is an explicit conversion from decimal to all integral types.
if (_exprSrc.GetConst() != null)
{
// Fold the constant cast if possible.
ConstCastResult result = _binder.bindConstantCast(_exprSrc, _exprTypeDest, _needsExprDest, out _exprDest, true);
if (result == ConstCastResult.Success)
{
return AggCastResult.Success; // else, don't fold and use a regular cast, below.
}
if (result == ConstCastResult.CheckFailure && 0 == (_flags & CONVERTTYPE.CHECKOVERFLOW))
{
return AggCastResult.Abort;
}
}
// All casts from decimal to integer types are bound as user-defined conversions.
bool bIsConversionOK = true;
if (_needsExprDest)
{
// According the language, this is a standard conversion, but it is implemented
// through a user-defined conversion. Because it's a standard conversion, we don't
// test the CONVERTTYPE.NOUDC flag here.
CType underlyingType = aggTypeDest.underlyingType();
bIsConversionOK = _binder.bindUserDefinedConversion(_exprSrc, _typeSrc, underlyingType, _needsExprDest, out _exprDest, false);
if (bIsConversionOK)
{
// upcast to the Enum type
_binder.bindSimpleCast(_exprDest, _exprTypeDest, out _exprDest);
}
}
return bIsConversionOK ? AggCastResult.Success : AggCastResult.Failure;
}