11/******************************************************************************************************
22 Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3- Version : 1.4.22 .0
3+ Version : 1.4.23 .0
44 (if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
55
66 Author : Coding Seb
@@ -860,6 +860,13 @@ public bool OptionNewFunctionEvaluationActive
860860 /// </summary>
861861 public bool OptionDetectExtensionMethodsOverloadsOnExtensionMethodNotFound { get ; set ; } = true ;
862862
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+
863870 #endregion
864871
865872 #region Reflection flags
@@ -3096,6 +3103,8 @@ protected virtual bool GetLambdaExpression(string expression, Stack<object> stac
30963103 . Cast < Match > ( ) . ToList ( )
30973104 . ConvertAll ( argMatch => argMatch . Value ) ;
30983105
3106+ bool inScriptAtDeclaration = inScript ;
3107+
30993108 stack . Push ( new InternalDelegate ( ( object [ ] args ) =>
31003109 {
31013110 var vars = new Dictionary < string , object > ( variables ) ;
@@ -3112,10 +3121,10 @@ protected virtual bool GetLambdaExpression(string expression, Stack<object> stac
31123121
31133122 object result = null ;
31143123
3115- if ( inScript && lambdaBody . StartsWith ( "{" ) && lambdaBody . EndsWith ( "}" ) )
3124+ if ( ( OptionCanDeclareMultiExpressionsLambdaInSimpleExpressionEvaluate || inScriptAtDeclaration )
3125+ && lambdaBody . StartsWith ( "{" ) && lambdaBody . EndsWith ( "}" ) )
31163126 {
31173127 result = ScriptEvaluate ( lambdaBody . Substring ( 1 , lambdaBody . Length - 2 ) ) ;
3118- inScript = true ;
31193128 }
31203129 else
31213130 {
0 commit comments