@@ -315,37 +315,32 @@ private static ICriterion ProcessSimpleExpression(BinaryExpression be)
315
315
if ( be . Left . NodeType == ExpressionType . Call && ( ( MethodCallExpression ) be . Left ) . Method . Name == "CompareString" )
316
316
return ProcessVisualBasicStringComparison ( be ) ;
317
317
318
- string property = FindMemberExpression ( be . Left ) ;
319
- System . Type propertyType = FindMemberType ( be . Left ) ;
318
+ return ProcessSimpleExpression ( be . Left , be . Right , be . NodeType ) ;
319
+ }
320
+
321
+ public static ICriterion ProcessSimpleExpression ( Expression left , Expression right , ExpressionType nodeType )
322
+ {
323
+ string property = FindMemberExpression ( left ) ;
324
+ System . Type propertyType = FindMemberType ( left ) ;
320
325
321
- object value = FindValue ( be . Right ) ;
326
+ object value = FindValue ( right ) ;
322
327
value = ConvertType ( value , propertyType ) ;
323
328
324
329
if ( value == null )
325
- return ProcessSimpleNullExpression ( property , be . NodeType ) ;
330
+ return ProcessSimpleNullExpression ( property , nodeType ) ;
326
331
327
- if ( ! _simpleExpressionCreators . ContainsKey ( be . NodeType ) )
328
- throw new Exception ( "Unhandled simple expression type: " + be . NodeType ) ;
332
+ if ( ! _simpleExpressionCreators . ContainsKey ( nodeType ) )
333
+ throw new Exception ( "Unhandled simple expression type: " + nodeType ) ;
329
334
330
- Func < string , object , ICriterion > simpleExpressionCreator = _simpleExpressionCreators [ be . NodeType ] ;
335
+ Func < string , object , ICriterion > simpleExpressionCreator = _simpleExpressionCreators [ nodeType ] ;
331
336
ICriterion criterion = simpleExpressionCreator ( property , value ) ;
332
337
return criterion ;
333
338
}
334
339
335
340
private static ICriterion ProcessVisualBasicStringComparison ( BinaryExpression be )
336
341
{
337
342
var methodCall = ( MethodCallExpression ) be . Left ;
338
- switch ( be . NodeType )
339
- {
340
- case ExpressionType . Equal :
341
- return ProcessSimpleExpression ( Expression . Equal ( methodCall . Arguments [ 0 ] , methodCall . Arguments [ 1 ] ) ) ;
342
-
343
- case ExpressionType . NotEqual :
344
- return ProcessSimpleExpression ( Expression . NotEqual ( methodCall . Arguments [ 0 ] , methodCall . Arguments [ 1 ] ) ) ;
345
-
346
- default :
347
- throw new Exception ( "Unhandled expression: " + be ) ;
348
- }
343
+ return ProcessSimpleExpression ( methodCall . Arguments [ 0 ] , methodCall . Arguments [ 1 ] , be . NodeType ) ;
349
344
}
350
345
351
346
private static ICriterion ProcessSimpleNullExpression ( string property , ExpressionType expressionType )
0 commit comments