1
1
/******************************************************************************************************
2
2
Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3
- Version : 1.4.22 .0
3
+ Version : 1.4.23 .0
4
4
(if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
5
5
6
6
Author : Coding Seb
@@ -860,6 +860,13 @@ public bool OptionNewFunctionEvaluationActive
860
860
/// </summary>
861
861
public bool OptionDetectExtensionMethodsOverloadsOnExtensionMethodNotFound { get ; set ; } = true ;
862
862
863
+ /// <summary>
864
+ /// If <c>true</c> Allow to define multi expression lambda in Expressions (not in script)<para/>
865
+ /// If <c>false</c> Can only define simple expression lambda if not in script
866
+ /// <para>Default value : <c>true</c></para>
867
+ /// </summary>
868
+ public bool OptionCanDeclareMultiExpressionsLambdaInSimpleExpressionEvaluate { get ; set ; } = true ;
869
+
863
870
#endregion
864
871
865
872
#region Reflection flags
@@ -3096,6 +3103,8 @@ protected virtual bool GetLambdaExpression(string expression, Stack<object> stac
3096
3103
. Cast < Match > ( ) . ToList ( )
3097
3104
. ConvertAll ( argMatch => argMatch . Value ) ;
3098
3105
3106
+ bool inScriptAtDeclaration = inScript ;
3107
+
3099
3108
stack . Push ( new InternalDelegate ( ( object [ ] args ) =>
3100
3109
{
3101
3110
var vars = new Dictionary < string , object > ( variables ) ;
@@ -3112,10 +3121,10 @@ protected virtual bool GetLambdaExpression(string expression, Stack<object> stac
3112
3121
3113
3122
object result = null ;
3114
3123
3115
- if ( inScript && lambdaBody . StartsWith ( "{" ) && lambdaBody . EndsWith ( "}" ) )
3124
+ if ( ( OptionCanDeclareMultiExpressionsLambdaInSimpleExpressionEvaluate || inScriptAtDeclaration )
3125
+ && lambdaBody . StartsWith ( "{" ) && lambdaBody . EndsWith ( "}" ) )
3116
3126
{
3117
3127
result = ScriptEvaluate ( lambdaBody . Substring ( 1 , lambdaBody . Length - 2 ) ) ;
3118
- inScript = true ;
3119
3128
}
3120
3129
else
3121
3130
{
0 commit comments