Example #1
0
            public override MetaObject SetMember(SetMemberAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.SetMember))
                {
                    return(CallMethodBinary(action, args[1], "SetMember"));
                }

                return(base.SetMember(action, args));
            }
Example #2
0
 public override MetaObject SetMember(SetMemberAction action, MetaObject[] args)
 {
     return new MetaObject(
         Expression.Call(
             Expression.Convert(Expression, LimitType),
             typeof(Duck).GetMethod("SetMember", new Type[] { typeof(SetMemberAction), typeof(object) }),
             Expression.Convert(Expression.Constant(action), typeof(SetMemberAction)),
             args[1].Expression
         ),
         Restrictions.TypeRestriction(Expression, LimitType)
     );
 }
Example #3
0
 /// <summary>
 /// Helper method for generating a MetaObject which calls a specific method declared on
 /// Dynamic w/ one additional parameter.
 /// </summary>
 private MetaObject CallMethodBinary(SetMemberAction action, MetaObject arg, string methodName)
 {
     return(new MetaObject(
                Expression.Call(
                    GetLimitedSelf(),
                    typeof(DynamicObject).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance),
                    Expression.Constant(action),
                    arg.Expression
                    ),
                GetRestrictions()
                ));
 }
Example #4
0
 /// <summary>
 /// Creates ActionExpression representing a SetMember action.
 /// </summary>
 /// <param name="name">The qualifier.</param>
 /// <param name="result">Type of the result desired (The ActionExpression is strongly typed)</param>
 /// <param name="arguments">Array of arguments for the action expression</param>
 /// <returns>New instance of the ActionExpression</returns>
 public static ActionExpression SetMember(SymbolId name, Type result, params Expression[] arguments)
 {
     return(ActionExpression(SetMemberAction.Make(name), arguments, result));
 }
Example #5
0
 /// <summary>
 /// Helper method for generating a MetaObject which calls a specific method declared on
 /// Dynamic w/ one additional parameter.
 /// </summary>
 private MetaObject CallMethodBinary(SetMemberAction action, MetaObject arg, string methodName)
 {
     return new MetaObject(
         Expression.Call(
             GetLimitedSelf(),
             typeof(DynamicObject).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance),
             Expression.Constant(action),
             arg.Expression
         ),
         GetRestrictions()
     );
 }
Example #6
0
            public override MetaObject SetMember(SetMemberAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.SetMember)) {
                    return CallMethodBinary(action, args[1], "SetMember");
                }

                return base.SetMember(action, args);
            }
Example #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 action determines the behavior.
 /// </summary>
 protected virtual void SetMember(SetMemberAction action, object value)
 {
     throw new NotSupportedException();
 }
Example #8
0
 protected override void SetMember(SetMemberAction action, object value)
 {
     if (_parameters == null) {
         _parameters = new Dictionary<string, object>();
     }
     _parameters[action.Name] = value;
 }
Example #9
0
        protected override void SetMember(SetMemberAction action, object value)
        {
            string name = action.Name;

            if (String.CompareOrdinal(name, "Value") == 0) {
                _element.Value = (value != null) ? value.ToString() : String.Empty;
            }

            base.SetMember(action, value);
        }
Example #10
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 action determines the behavior.
 /// </summary>
 protected virtual void SetMember(SetMemberAction action, object value)
 {
     throw new NotSupportedException();
 }