FallbackConvert() public method

Performs the binding of the dynamic convert operation if the target dynamic object cannot bind.
public FallbackConvert ( DynamicMetaObject target ) : DynamicMetaObject
target DynamicMetaObject The target of the dynamic convert operation.
return DynamicMetaObject
コード例 #1
0
 public override DynamicMetaObject/*!*/ BindConvert(ConvertBinder/*!*/ binder) {
     var protocolConversion = ProtocolConversionAction.TryGetDefaultConversionAction(Context, binder.Type);
     if (protocolConversion != null) {
         return protocolConversion.Bind(this, DynamicMetaObject.EmptyMetaObjects);
     } else {
         return binder.FallbackConvert(this);
     }
 }
コード例 #2
0
            public override DynamicMetaObject BindConvert(ConvertBinder binder) {
                if (IsOverridden("TryConvert")) {
                    return CallMethodWithResult("TryConvert", binder, NoArgs, (e) => binder.FallbackConvert(this, e));
                }

                return base.BindConvert(binder);
            }
コード例 #3
0
 /// <summary>
 /// Performs the binding of the dynamic conversion operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="ConvertBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindConvert(ConvertBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackConvert(this);
 }
コード例 #4
0
ファイル: TotemType.cs プロジェクト: Alxandr/IronTotem
            public override DynamicMetaObject BindConvert(ConvertBinder binder)
            {
                var type = binder.Type;
                if (binder is TotemConversionBinder)
                    type = ((TotemConversionBinder)binder).Type;

                var conversions = _type.GetConversions(type, binder.Explicit);
                foreach (var c in conversions)
                {
                    var ret = c(_type, this);
                    if (ret != null)
                    {
                        if (ret.Expression.Type != binder.Type)
                            ret = new DynamicMetaObject(
                                Expression.Convert(ret.Expression, binder.Type),
                                ret.Restrictions
                            );
                        return ret;
                    }
                }

                if (type == typeof(bool) && binder.Explicit)
                    throw Assert.Unreachable;

                DynamicMetaObject result;
                if (_type.HandleConvert(binder, this, out result))
                    return result;

                var fallback = binder.FallbackConvert(this, result);
                //BindingRestrictions restrictions = fallback.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(Expression, LimitType));
                //foreach (var arg in indexes)
                //    restrictions = restrictions.Merge(BindingRestrictions.GetTypeRestriction(arg.Expression, arg.LimitType));

                //return new DynamicMetaObject(
                //    AssertImplemented(
                //        Expression.Call(
                //            Expression.Constant(_type, typeof(TotemType)),
                //            TotemType.GetMissingIndexInfo,
                //            Expression,
                //            Expression.NewArrayInit(
                //                typeof(object),
                //                ArrayUtils.ConvertAll(indexes, i => i.Expression)
                //            )
                //        ),
                //        fallback.Expression
                //    ),
                //    restrictions
                //);
                return fallback;
            }
コード例 #5
0
 /// <summary>
 /// Performs the binding of the dynamic conversion operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="ConvertBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindConvert(ConvertBinder binder)
 {
     ArgumentNullException.ThrowIfNull(binder);
     return(binder.FallbackConvert(this));
 }
コード例 #6
0
 /// <summary>
 /// Performs the binding of the dynamic conversion operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="ConvertBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindConvert(ConvertBinder binder)
 {
     ContractUtils.RequiresNotNull(binder, "binder");
     return(binder.FallbackConvert(this));
 }
コード例 #7
0
 public override DynamicMetaObject BindConvert(ConvertBinder binder)
 {
     Fallback fallback = null;
     if (!this.IsOverridden("TryConvert"))
     {
         return base.BindConvert(binder);
     }
     if (fallback == null)
     {
         fallback = e => binder.FallbackConvert(this, e);
     }
     return this.CallMethodWithResult("TryConvert", binder, NoArgs, fallback);
 }
コード例 #8
0
            public override DynamicMetaObject BindConvert(ConvertBinder binder)
            {
                if (IsOverridden(nameof(DynamicObject.TryConvert)))
                {
                    return(CallMethodWithResult(nameof(DynamicObject.TryConvert), binder, s_noArgs, (e) => binder.FallbackConvert(this, e)));
                }

                return(base.BindConvert(binder));
            }
コード例 #9
0
 public override DynamicMetaObject BindConvert(ConvertBinder/*!*/ conversion) {
     if (conversion.Type.IsSubclassOf(typeof(Delegate))) {
         return MakeDelegateTarget(conversion, conversion.Type, Restrict(typeof(BuiltinFunction)));
     }
     return conversion.FallbackConvert(this);
 }
コード例 #10
0
 public override DynamicMetaObject BindConvert( ConvertBinder binder )
 {
     return binder.FallbackConvert( _baseMetaObject, AddTypeRestrictions( _metaObject.BindConvert( binder ) ) );
 }