public override MetaObject SetMember(SetMemberAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.SetMember)) { return(CallMethodBinary(action, args[1], "SetMember")); } return(base.SetMember(action, args)); }
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) ); }
/// <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() )); }
/// <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)); }
/// <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() ); }
public override MetaObject SetMember(SetMemberAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.SetMember)) { return CallMethodBinary(action, args[1], "SetMember"); } return base.SetMember(action, args); }
/// <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(); }
protected override void SetMember(SetMemberAction action, object value) { if (_parameters == null) { _parameters = new Dictionary<string, object>(); } _parameters[action.Name] = value; }
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); }