Esempio n. 1
0
 public static bool TryBindSetMember(SetMemberBinder binder, ref MetaObject instance, MetaObject value) {
     if (TryGetMetaObject(ref instance)) {
         instance = instance.BindSetMember(binder, value);
         return true;
     }
     return false;
 }
 public override MetaObject BindSetMember(SetMemberBinder binder, MetaObject value) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackSetMember(UnwrapSelf(), value);
 }
Esempio n. 3
0
            public override MetaObject BindSetMember(SetMemberBinder binder, MetaObject value) {
                ContractUtils.RequiresNotNull(binder, "binder");
                ContractUtils.RequiresNotNull(value, "value");

                ExpandoClass klass;
                int index;

                ExpandoClass originalClass = GetClassEnsureIndex(binder.Name, binder.IgnoreCase, out klass, out index);

                string methodName = binder.IgnoreCase ? "ExpandoSetValueIgnoreCase" : "ExpandoSetValue";

                return new MetaObject(
                    AddDynamicTestAndDefer(
                        binder,
                        new MetaObject[] { this, value },
                        klass,
                        originalClass,
                        Expression.Convert(
                            Expression.Call(
                                typeof(RuntimeOps).GetMethod(methodName),
                                GetLimitedSelf(),
                                Expression.Constant(klass),
                                Expression.Constant(index),
                                Helpers.Convert(
                                    value.Expression,
                                    typeof(object)
                                )
                            ),
                            typeof(object)
                        )
                    ),
                    GetRestrictions()
                );
            }
Esempio n. 4
0
        private MetaObject TryEventHandlerNoop(SetMemberBinder binder, MetaObject value) {
            ComEventDesc @event;
            if (_self.TryGetEventHandler(binder.Name, out @event) && value.LimitType == typeof(BoundDispEvent)) {
                // Drop the event property set.
                return new MetaObject(
                    Expression.Constant(null),
                    value.Restrictions.Merge(IDispatchRestriction()).Merge(Restrictions.GetTypeRestriction(value.Expression, typeof(BoundDispEvent)))
                );
            }

            return null;
        }
Esempio n. 5
0
        private MetaObject TryPropertyPut(SetMemberBinder binder, MetaObject value) {
            ComMethodDesc method;
            if (_self.TryGetPropertySetter(binder.Name, out method, value.LimitType) ||
                _self.TryGetPropertySetterExplicit(binder.Name, out method, value.LimitType)) {
                Restrictions restrictions = IDispatchRestriction();
                Expression dispatch =
                    Expression.Property(
                        Helpers.Convert(Expression, typeof(IDispatchComObject)),
                        typeof(IDispatchComObject).GetProperty("DispatchObject")
                    );

                return new ComInvokeBinder(
                    new ArgumentInfo[0],
                    new[] { value },
                    restrictions,
                    Expression.Constant(method),
                    dispatch,
                    method
                ).Invoke();
            }

            return null;
        }
Esempio n. 6
0
        public override MetaObject BindSetMember(SetMemberBinder binder, MetaObject value) {
            ContractUtils.RequiresNotNull(binder, "binder");

            return
                // 1. Check for simple property put
                TryPropertyPut(binder, value) ??

                // 2. Check for event handler hookup where the put is dropped
                TryEventHandlerNoop(binder, value) ??

                // 3. Fallback
                base.BindSetMember(binder, value);
        }
Esempio n. 7
0
 /// <summary>
 /// When overridden in a derived class provides the non-Meta implementation of setting a member.
 /// 
 /// When not overridden the call site requesting the binder determines the behavior.
 /// </summary>
 public virtual bool TrySetMember(SetMemberBinder binder, object value) {
     throw new NotSupportedException();
 }
Esempio n. 8
0
            public override MetaObject BindSetMember(SetMemberBinder binder, MetaObject value) {
                if (IsOverridden("TrySetMember")) {
                    return CallMethodReturnLast("TrySetMember", binder, GetArgs(value), (e) => binder.FallbackSetMember(this, value, e));
                }

                return base.BindSetMember(binder, value);
            }
Esempio n. 9
0
 public virtual MetaObject BindSetMember(SetMemberBinder binder, MetaObject value) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackSetMember(this, value);
 }