/// <summary>
        /// Helper to produce an error when a conversion cannot occur
        /// </summary>
        private DynamicMetaObject MakeErrorTarget(Type toType, ConversionResultKind kind, BindingRestrictions restrictions, DynamicMetaObject arg)
        {
            DynamicMetaObject target;

            switch (kind)
            {
            case ConversionResultKind.ImplicitCast:
            case ConversionResultKind.ExplicitCast:
                target = MakeError(
                    MakeConversionError(toType, arg.Expression),
                    restrictions,
                    toType
                    );
                break;

            case ConversionResultKind.ImplicitTry:
            case ConversionResultKind.ExplicitTry:
                target = new DynamicMetaObject(
                    GetTryConvertReturnValue(toType),
                    restrictions
                    );
                break;

            default:
                throw new InvalidOperationException(kind.ToString());
            }

            return(target);
        }
Exemplo n.º 2
0
        /// <summary>Helper to produce an error when a conversion cannot occur</summary>
        private static MSAst MakeErrorTarget(Type toType, ConversionResultKind kind, MSAst arg)
        {
            MSAst target;

            switch (kind)
            {
            case ConversionResultKind.ImplicitCast:
            case ConversionResultKind.ExplicitCast:
                //target = DefaultBinder.MakeError(
                //    _binder.Binder.MakeConversionError(toType, arg),
                //    toType);
                target = arg;
                break;

            case ConversionResultKind.ImplicitTry:
            case ConversionResultKind.ExplicitTry:
                target = GetTryConvertReturnValue(toType);
                break;

            default:
                throw new InvalidOperationException(kind.ToString());
            }

            return(target);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Helper to produce an error when a conversion cannot occur
        /// </summary>
        private DynamicMetaObject MakeErrorTarget(Type toType, ConversionResultKind kind, BindingRestrictions restrictions, DynamicMetaObject arg) {
            DynamicMetaObject target;

            switch (kind) {
                case ConversionResultKind.ImplicitCast:
                case ConversionResultKind.ExplicitCast:
                    target = MakeError(
                        MakeConversionError(toType, arg.Expression),
                        restrictions,
                        toType
                    );
                    break;
                case ConversionResultKind.ImplicitTry:
                case ConversionResultKind.ExplicitTry:
                    target = new DynamicMetaObject(
                        GetTryConvertReturnValue(toType),
                        restrictions
                    );
                    break;
                default:
                    throw new InvalidOperationException(kind.ToString());
            }

            return target;
        }