FallbackSetIndex() public method

Performs the binding of the dynamic set index operation if the target dynamic object cannot bind.
public FallbackSetIndex ( DynamicMetaObject target, DynamicMetaObject indexes, DynamicMetaObject value ) : DynamicMetaObject
target DynamicMetaObject The target of the dynamic set index operation.
indexes DynamicMetaObject The arguments of the dynamic set index operation.
value DynamicMetaObject The value to set to the collection.
return DynamicMetaObject
コード例 #1
0
            public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
            {
                Fallback fallback = null;

                if (!this.IsOverridden("TrySetIndex"))
                {
                    return(base.BindSetIndex(binder, indexes, value));
                }
                if (fallback == null)
                {
                    fallback = e => binder.FallbackSetIndex(this, indexes, value, e);
                }
                return(this.CallMethodReturnLast("TrySetIndex", binder, GetArgArray(indexes, value), fallback));
            }
コード例 #2
0
 public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackSetIndex(UnwrapSelf(), indexes, value);
 }
コード例 #3
0
 /// <summary>
 /// Performs the binding of the dynamic set index operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="SetIndexBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the set index operation.</param>
 /// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set index operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
 {
     ContractUtils.RequiresNotNull(binder, "binder");
     return(binder.FallbackSetIndex(this, indexes, value));
 }
コード例 #4
0
            public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
                if (IsOverridden("TrySetIndex")) {
                    return CallMethodReturnLast("TrySetIndex", binder, DynamicMetaObject.GetExpressions(indexes), value.Expression, (e) => binder.FallbackSetIndex(this, indexes, value, e));
                }

                return base.BindSetIndex(binder, indexes, value);
            }
コード例 #5
0
            public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
            {
                if (IsOverridden("TrySetIndex"))
                {
                    return(CallMethodReturnLast("TrySetIndex", binder, DynamicMetaObject.GetExpressions(indexes), value.Expression, (e) => binder.FallbackSetIndex(this, indexes, value, e)));
                }

                return(base.BindSetIndex(binder, indexes, value));
            }
コード例 #6
0
 /// <summary>
 /// Performs the binding of the dynamic set index operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="SetIndexBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the set index operation.</param>
 /// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set index operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackSetIndex(this, indexes, value);
 }
コード例 #7
0
ファイル: TotemType.cs プロジェクト: Alxandr/IronTotem
            public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
            {
                var index = _type.GetIndex(binder.CallInfo.ArgumentCount);
                if (index != null && index.Getters != null)
                {
                    var setCall = TotemProtocol.ResolveOverload(
                        binder,
                        _type,
                        binder.CallInfo,
                        _type.Name + ".<set_index>",
                        index.Setters,
                        this,
                        ArrayUtils.Append(indexes, value),
                        nonCountingArgs: 1
                    );
                    return new DynamicMetaObject(
                        Expression.Block(
                            setCall.Expression,
                            value.Expression
                        ),
                        setCall.Restrictions
                    );
                }

                var fallback = binder.FallbackSetIndex(this, indexes, value);
                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.SetMissingIndexInfo,
                            Expression,
                            Expression.NewArrayInit(
                                typeof(object),
                                ArrayUtils.ConvertAll(indexes, i => i.Expression)
                            )
                        ),
                        fallback.Expression
                    ),
                    restrictions
                );
            }
コード例 #8
0
 /// <summary>
 /// Performs the binding of the dynamic set index operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="SetIndexBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the set index operation.</param>
 /// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set index operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
 {
     ArgumentNullException.ThrowIfNull(binder);
     return(binder.FallbackSetIndex(this, indexes, value));
 }
コード例 #9
0
 public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
 {
     Fallback fallback = null;
     if (!this.IsOverridden("TrySetIndex"))
     {
         return base.BindSetIndex(binder, indexes, value);
     }
     if (fallback == null)
     {
         fallback = e => binder.FallbackSetIndex(this, indexes, value, e);
     }
     return this.CallMethodReturnLast("TrySetIndex", binder, GetArgArray(indexes, value), fallback);
 }
コード例 #10
0
 /// <summary>
 ///     Performs the binding of the dynamic set index operation.
 /// </summary>
 /// <param name="binder">
 ///     An instance of the <see cref="T:System.Dynamic.SetIndexBinder" /> that represents the details of the dynamic operation.
 /// </param>
 /// <param name="indexes">
 ///     An array of <see cref="T:System.Dynamic.DynamicMetaObject" /> instances - indexes for the set index operation.
 /// </param>
 /// <param name="value">
 ///     The <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the value for the set index operation.
 /// </param>
 /// <returns>
 ///     The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding.
 /// </returns>
 public override DynamicMetaObject BindSetIndex( SetIndexBinder binder,
     DynamicMetaObject[] indexes,
     DynamicMetaObject value)
 {
     return ApplyBinding( meta => meta.BindSetIndex( binder, indexes, value ),
                          ( target, errorSuggestion ) =>
                          binder.FallbackSetIndex( target, indexes, value, errorSuggestion ) );
 }
コード例 #11
0
 public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
 {
     return binder.FallbackSetIndex(UnwrapSelf(), indexes, value);
 }
コード例 #12
0
 public override DynamicMetaObject BindSetIndex( SetIndexBinder binder,
                                                 DynamicMetaObject[] indexes,
                                                 DynamicMetaObject value )
 {
     return binder.FallbackSetIndex( _baseMetaObject,
                                     indexes,
                                     AddTypeRestrictions( _metaObject.BindSetIndex( binder, indexes, value ) ) );
 }