FallbackGetIndex() public method

Performs the binding of the dynamic get index operation if the target dynamic object cannot bind.
public FallbackGetIndex ( DynamicMetaObject target, DynamicMetaObject indexes ) : DynamicMetaObject
target DynamicMetaObject The target of the dynamic get index operation.
indexes DynamicMetaObject The arguments of the dynamic get index operation.
return DynamicMetaObject
コード例 #1
0
            public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes)
            {
                Fallback fallback = null;

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

                return base.BindGetIndex(binder, indexes);
            }
コード例 #5
0
            public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes)
            {
                if (IsOverridden("TryGetIndex"))
                {
                    return(CallMethodWithResult("TryGetIndex", binder, DynamicMetaObject.GetExpressions(indexes), (e) => binder.FallbackGetIndex(this, indexes, e)));
                }

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

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