17 using System.Linq.Expressions;
18 using System.Reflection;
28 private readonly MethodInfo _setPropertyMethodInfo;
29 private readonly MethodInfo _getPropertyMethodInfo;
39 Expression expression,
41 MethodInfo setPropertyMethodInfo,
42 MethodInfo getPropertyMethodInfo
44 : base(expression, BindingRestrictions.Empty, value)
46 _setPropertyMethodInfo = setPropertyMethodInfo;
47 _getPropertyMethodInfo = getPropertyMethodInfo;
56 public override DynamicMetaObject
BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
59 var restrictions = BindingRestrictions.GetTypeRestriction(Expression, LimitType);
61 var args =
new Expression[]
64 Expression.Constant(binder.Name),
67 Expression.Convert(value.Expression, typeof (
object))
71 var
self = Expression.Convert(Expression, LimitType);
73 var call = Expression.Call(
self, _setPropertyMethodInfo, args);
75 return new DynamicMetaObject(call, restrictions);
84 var restrictions = BindingRestrictions.GetTypeRestriction(Expression, LimitType);
87 var args =
new Expression[]
90 Expression.Constant(binder.Name)
94 var
self = Expression.Convert(Expression, LimitType);
96 var call = Expression.Call(
self, _getPropertyMethodInfo, args);
98 return new DynamicMetaObject(call, restrictions);