Skip to content

Commit dc5d765

Browse files
authored
Merge pull request #90 from codingseb/dev
Dev
2 parents 08f7c92 + f60cf63 commit dc5d765

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CodingSeb.ExpressionEvaluator/CodingSeb.ExpressionEvaluator.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<Product>CodingSeb.ExpressionEvaluator</Product>
66
<Description>A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts</Description>
77
<Copyright>Copyright © Coding Seb 2017</Copyright>
8-
<Version>1.4.22.0</Version>
9-
<AssemblyVersion>1.4.22.0</AssemblyVersion>
10-
<FileVersion>1.4.22.0</FileVersion>
8+
<Version>1.4.23.0</Version>
9+
<AssemblyVersion>1.4.23.0</AssemblyVersion>
10+
<FileVersion>1.4.23.0</FileVersion>
1111
<OutputPath>bin\$(Configuration)\</OutputPath>
1212
<Authors>Coding Seb</Authors>
1313
<PackageId>CodingSeb.ExpressionEvaluator</PackageId>
@@ -19,7 +19,8 @@
1919
<PackageIconUrl>https://github.com/codingseb/ExpressionEvaluator/blob/master/Icon.png?raw=true</PackageIconUrl>
2020
<PackageIcon>Icon.png</PackageIcon>
2121
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
22-
<PackageReleaseNotes>* Add Support for method call with parameters with default value</PackageReleaseNotes>
22+
<PackageReleaseNotes>* Add the option OptionCanDeclareMultiExpressionsLambdaInSimpleExpressionEvaluate (default is true)
23+
* Allow to declare and call multi expressions lambda in simple expression Evaluate</PackageReleaseNotes>
2324
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2425
<RepositoryUrl>https://github.com/codingseb/ExpressionEvaluator</RepositoryUrl>
2526
</PropertyGroup>

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

Comments
 (0)