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); } }
public override DynamicMetaObject BindConvert(ConvertBinder binder) { if (IsOverridden("TryConvert")) { return CallMethodWithResult("TryConvert", binder, NoArgs, (e) => binder.FallbackConvert(this, e)); } return base.BindConvert(binder); }
/// <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); }
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; }
/// <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)); }
/// <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)); }
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); }
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)); }
public override DynamicMetaObject BindConvert(ConvertBinder/*!*/ conversion) { if (conversion.Type.IsSubclassOf(typeof(Delegate))) { return MakeDelegateTarget(conversion, conversion.Type, Restrict(typeof(BuiltinFunction))); } return conversion.FallbackConvert(this); }
public override DynamicMetaObject BindConvert( ConvertBinder binder ) { return binder.FallbackConvert( _baseMetaObject, AddTypeRestrictions( _metaObject.BindConvert( binder ) ) ); }