Microsoft.CSharp.RuntimeBinder.Semantics.CType.StripNubs C# (CSharp) Méthode

StripNubs() public méthode

public StripNubs ( ) : CType
Résultat CType
        public CType StripNubs()
        {
            CType type;
            for (type = this; type.IsNullableType(); type = type.AsNullableType().GetUnderlyingType())
                ;
            return type;
        }
        public CType StripNubs(out int pcnub)

Same methods

CType::StripNubs ( int &pcnub ) : CType

Usage Example

Exemple #1
0
            private bool bindExplicitConversionFromNub()
            {
                Debug.Assert(_typeSrc != null);
                Debug.Assert(_typeDest != null);

                // If S and T are value types and there is a builtin conversion from S => T then there is an
                // explicit conversion from S? => T that throws on null.
                if (_typeDest.IsValType() && _binder.BindExplicitConversion(null, _typeSrc.StripNubs(), _exprTypeDest, _pDestinationTypeForLambdaErrorReporting, _flags | CONVERTTYPE.NOUDC))
                {
                    if (_needsExprDest)
                    {
                        Expr valueSrc = _exprSrc;
                        // This is a holdover from the days when you could have nullable of nullable.
                        // Can we remove this loop?
                        while (valueSrc.Type is NullableType)
                        {
                            valueSrc = _binder.BindNubValue(valueSrc);
                        }
                        Debug.Assert(valueSrc.Type == _typeSrc.StripNubs());
                        if (!_binder.BindExplicitConversion(valueSrc, valueSrc.Type, _exprTypeDest, _pDestinationTypeForLambdaErrorReporting, _needsExprDest, out _exprDest, _flags | CONVERTTYPE.NOUDC))
                        {
                            VSFAIL("BindExplicitConversion failed unexpectedly");
                            return(false);
                        }
                        if (_exprDest is ExprUserDefinedConversion udc)
                        {
                            udc.Argument = _exprSrc;
                        }
                    }
                    return(true);
                }

                if ((_flags & CONVERTTYPE.NOUDC) == 0)
                {
                    return(_binder.bindUserDefinedConversion(_exprSrc, _typeSrc, _typeDest, _needsExprDest, out _exprDest, false));
                }
                return(false);
            }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::StripNubs