1
- using System ;
1
+ using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Dynamic ;
4
4
using System . Linq ;
@@ -91,12 +91,12 @@ public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
91
91
public override DynamicMetaObject BindSetMember ( SetMemberBinder binder , DynamicMetaObject value )
92
92
{
93
93
var ctor = CtorWithStringAndValue ;
94
- Expression objectExpression = value . Expression ;
95
- if ( ( value . Value != null && value . Value . GetType ( ) . IsValue ( ) ) ||
96
- ( value . Value == null && Nullable . GetUnderlyingType ( objectExpression . Type ) != null ) )
97
- {
98
- objectExpression = Expression . Convert ( objectExpression , typeof ( object ) ) ;
99
- }
94
+ Expression objectExpression = value . Expression ;
95
+ if ( ( value . Value != null && value . Value . GetType ( ) . IsValue ( ) ) ||
96
+ ( value . Value == null && Nullable . GetUnderlyingType ( objectExpression . Type ) != null ) )
97
+ {
98
+ objectExpression = Expression . Convert ( objectExpression , typeof ( object ) ) ;
99
+ }
100
100
var ctorArguments = new [ ] { Expression . Constant ( binder . Name ) , objectExpression } ;
101
101
102
102
return new DynamicMetaObject (
@@ -112,13 +112,13 @@ public override DynamicMetaObject BindInvokeMember(
112
112
var expression = Expression . New ( CtorWithExpressionAndExpressionFunction ,
113
113
new [ ]
114
114
{
115
- Expression . Constant ( this . Value ) ,
115
+ Expression . Constant ( this . Value ) ,
116
116
Expression . Constant ( new ExpressionFunction ( binder . Name , args . Select ( x => x . Value ) ) )
117
- } ) ;
118
-
117
+ } ) ;
118
+ BindingRestrictions bindingRestrictions = args . Aggregate ( BindingRestrictions . Empty , ( acc , x ) => acc . Merge ( BindingRestrictions . GetInstanceRestriction ( x . Expression , x . Value ) ) ) ;
119
119
return new DynamicMetaObject (
120
120
expression ,
121
- BindingRestrictions . GetTypeRestriction ( Expression , LimitType ) ) ;
121
+ bindingRestrictions ) ;
122
122
}
123
123
else if ( string . Equals ( binder . Name , ODataLiteral . Any , StringComparison . OrdinalIgnoreCase ) ||
124
124
string . Equals ( binder . Name , ODataLiteral . All , StringComparison . OrdinalIgnoreCase ) )
0 commit comments