Esempio n. 1
0
        public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
        {
            ContractUtils.RequiresNotNull(binder, "binder");

            ComMethodDesc setItem;

            if (_self.TryGetSetItem(out setItem))
            {
                bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref indexes);
                isByRef = isByRef.AddLast(false);

                var result = BindComInvoke(indexes.AddLast(value), setItem, binder.CallInfo, isByRef);

                // Make sure to return the value; some languages need it.
                return(new DynamicMetaObject(
                           Expression.Block(result.Expression, Expression.Convert(value.Expression, typeof(object))),
                           result.Restrictions
                           ));
            }

            return(base.BindSetIndex(binder, indexes, value));
        }