@@ -283,8 +283,8 @@ private IParseTreeValue EvaluateArithmeticOp(string opSymbol, IParseTreeValue LH
283
283
return _valueFactory . CreateExpression ( $ "{ LHS . Token } { opSymbol } { RHS . Token } ", opProvider . OperatorDeclaredType ) ;
284
284
}
285
285
286
- if ( ! LHS . TryLetCoerce ( opProvider . OperatorEffectiveType , out IParseTreeValue effLHS )
287
- || ! RHS . TryLetCoerce ( opProvider . OperatorEffectiveType , out IParseTreeValue effRHS ) )
286
+ if ( ! LHS . TryLetCoerce ( opProvider . OperatorEffectiveType , out var effLHS )
287
+ || ! RHS . TryLetCoerce ( opProvider . OperatorEffectiveType , out var effRHS ) )
288
288
{
289
289
return _valueFactory . CreateExpression ( $ "{ LHS . Token } { opSymbol } { RHS . Token } ", opProvider . OperatorDeclaredType ) ;
290
290
}
@@ -299,45 +299,45 @@ private IParseTreeValue EvaluateArithmeticOp(string opSymbol, IParseTreeValue LH
299
299
300
300
if ( opSymbol . Equals ( ArithmeticOperators . MULTIPLY ) )
301
301
{
302
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => { return a * b ; } , ( double a , double b ) => { return a * b ; } ) , opProvider . OperatorDeclaredType ) ;
302
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => a * b , ( double a , double b ) => a * b ) , opProvider . OperatorDeclaredType ) ;
303
303
}
304
- else if ( opSymbol . Equals ( ArithmeticOperators . DIVIDE ) )
304
+ if ( opSymbol . Equals ( ArithmeticOperators . DIVIDE ) )
305
305
{
306
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => { return a / b ; } , ( double a , double b ) => { return a / b ; } ) , opProvider . OperatorDeclaredType ) ;
306
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => a / b , ( double a , double b ) => a / b ) , opProvider . OperatorDeclaredType ) ;
307
307
}
308
- else if ( opSymbol . Equals ( ArithmeticOperators . INTEGER_DIVIDE ) )
308
+ if ( opSymbol . Equals ( ArithmeticOperators . INTEGER_DIVIDE ) )
309
309
{
310
310
return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , IntDivision , IntDivision ) , opProvider . OperatorDeclaredType ) ;
311
311
}
312
- else if ( opSymbol . Equals ( ArithmeticOperators . PLUS ) )
312
+ if ( opSymbol . Equals ( ArithmeticOperators . PLUS ) )
313
313
{
314
314
if ( opProvider . OperatorEffectiveType . Equals ( Tokens . String ) )
315
315
{
316
316
return _valueFactory . CreateValueType ( Concatenate ( LHS , RHS ) , opProvider . OperatorDeclaredType ) ;
317
317
}
318
318
if ( opProvider . OperatorEffectiveType . Equals ( Tokens . Date ) )
319
319
{
320
- var result = _valueFactory . CreateDeclaredType ( Calculate ( effLHS , effRHS , null , ( double a , double b ) => { return a + b ; } ) , Tokens . Double ) ;
320
+ var result = _valueFactory . CreateDeclaredType ( Calculate ( effLHS , effRHS , null , ( double a , double b ) => a + b ) , Tokens . Double ) ;
321
321
return _valueFactory . CreateDate ( result . AsDouble ( ) ) ;
322
322
}
323
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => { return a + b ; } , ( double a , double b ) => { return a + b ; } ) , opProvider . OperatorDeclaredType ) ;
323
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => a + b , ( double a , double b ) => a + b ) , opProvider . OperatorDeclaredType ) ;
324
324
}
325
- else if ( opSymbol . Equals ( ArithmeticOperators . MINUS ) )
325
+ if ( opSymbol . Equals ( ArithmeticOperators . MINUS ) )
326
326
{
327
327
if ( LHS . ValueType . Equals ( Tokens . Date ) && RHS . ValueType . Equals ( Tokens . Date ) )
328
328
{
329
329
return _valueFactory . CreateDate ( LHS . AsDouble ( ) - RHS . AsDouble ( ) ) ;
330
330
}
331
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => { return a - b ; } , ( double a , double b ) => { return a - b ; } ) , opProvider . OperatorDeclaredType ) ;
331
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => a - b , ( double a , double b ) => a - b ) , opProvider . OperatorDeclaredType ) ;
332
332
}
333
- else if ( opSymbol . Equals ( ArithmeticOperators . EXPONENT ) )
333
+ if ( opSymbol . Equals ( ArithmeticOperators . EXPONENT ) )
334
334
{
335
335
//Math.Pow only takes doubles, so the decimal conversion option is null
336
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , null , ( double a , double b ) => { return Math . Pow ( a , b ) ; } ) , opProvider . OperatorDeclaredType ) ;
336
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , null , Math . Pow ) , opProvider . OperatorDeclaredType ) ;
337
337
}
338
- else if ( opSymbol . Equals ( ArithmeticOperators . MODULO ) )
338
+ if ( opSymbol . Equals ( ArithmeticOperators . MODULO ) )
339
339
{
340
- return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => { return a % b ; } , ( double a , double b ) => { return a % b ; } ) , opProvider . OperatorDeclaredType ) ;
340
+ return _valueFactory . CreateValueType ( Calculate ( effLHS , effRHS , ( decimal a , decimal b ) => a % b , ( double a , double b ) => a % b ) , opProvider . OperatorDeclaredType ) ;
341
341
}
342
342
343
343
//ArithmeticOperators.AMPERSAND
@@ -377,9 +377,9 @@ private string Calculate(IParseTreeValue LHS, IParseTreeValue RHS, Func<decimal,
377
377
378
378
if ( ! ( DecimalCalc is null ) && LHS . TryLetCoerce ( out decimal lhsValue ) && RHS . TryLetCoerce ( out decimal rhsValue ) )
379
379
{
380
- return DecimalCalc ( lhsValue , rhsValue ) . ToString ( ) ;
380
+ return DecimalCalc ( lhsValue , rhsValue ) . ToString ( CultureInfo . InvariantCulture ) ;
381
381
}
382
- return DoubleCalc ( LHS . AsDouble ( ) , RHS . AsDouble ( ) ) . ToString ( ) ;
382
+ return DoubleCalc ( LHS . AsDouble ( ) , RHS . AsDouble ( ) ) . ToString ( CultureInfo . InvariantCulture ) ;
383
383
}
384
384
385
385
private string Compare ( IParseTreeValue LHS , IParseTreeValue RHS , Func < decimal , decimal , bool > DecimalCompare , Func < double , double , bool > DoubleCompare )
0 commit comments