Skip to content

Commit 09102f2

Browse files
committed
Generics types in var and func onthe fly events (To Test)
1 parent b46eb81 commit 09102f2

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 23 additions & 9 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.3.7.0
3+
Version : 1.3.7.1
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
@@ -1741,7 +1741,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
17411741
}
17421742
else
17431743
{
1744-
FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg(varFuncName, Evaluate, funcArgs, this, obj);
1744+
FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg(varFuncName, Evaluate, funcArgs, this, obj, string.IsNullOrEmpty(genericsTypes) ? null : GetConcreteTypes(genericsTypes).ToList());
17451745

17461746
EvaluateFunction?.Invoke(this, functionEvaluationEventArg);
17471747

@@ -1835,7 +1835,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
18351835
}
18361836
else
18371837
{
1838-
FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg(varFuncName, Evaluate, funcArgs, this);
1838+
FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg(varFuncName, Evaluate, funcArgs, this, genericTypes: string.IsNullOrEmpty(genericsTypes) ? null : GetConcreteTypes(genericsTypes).ToList());
18391839

18401840
EvaluateFunction?.Invoke(this, functionEvaluationEventArg);
18411841

@@ -1946,7 +1946,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
19461946
}
19471947
else
19481948
{
1949-
VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg(varFuncName, this, obj);
1949+
VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg(varFuncName, this, obj, string.IsNullOrEmpty(genericsTypes) ? null : GetConcreteTypes(genericsTypes).ToList());
19501950

19511951
EvaluateVariable?.Invoke(this, variableEvaluationEventArg);
19521952

@@ -2086,7 +2086,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
20862086
}
20872087
else
20882088
{
2089-
VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg(varFuncName, this);
2089+
VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg(varFuncName, this, genericTypes: string.IsNullOrEmpty(genericsTypes) ? null : GetConcreteTypes(genericsTypes).ToList());
20902090

20912091
EvaluateVariable?.Invoke(this, variableEvaluationEventArg);
20922092

@@ -3283,11 +3283,12 @@ public class VariableEvaluationEventArg : EventArgs
32833283
/// Constructor of the VariableEvaluationEventArg
32843284
/// </summary>
32853285
/// <param name="name">The name of the variable to Evaluate</param>
3286-
public VariableEvaluationEventArg(string name, ExpressionEvaluator evaluator = null, object onInstance = null)
3286+
public VariableEvaluationEventArg(string name, ExpressionEvaluator evaluator = null, object onInstance = null, List<Type> genericTypes = null)
32873287
{
32883288
Name = name;
32893289
This = onInstance;
32903290
Evaluator = evaluator;
3291+
GenericTypes = genericTypes ?? new List<Type>();
32913292
}
32923293

32933294
/// <summary>
@@ -3316,7 +3317,7 @@ public object Value
33163317
public bool HasValue { get; set; } = false;
33173318

33183319
/// <summary>
3319-
/// In the case of on the fly instance property definition the instance of the object on which this Function is called.
3320+
/// In the case of on the fly instance property definition the instance of the object on which this Property is called.
33203321
/// Otherwise is set to null.
33213322
/// </summary>
33223323
public object This { get; } = null;
@@ -3325,19 +3326,26 @@ public object Value
33253326
/// A reference on the current expression evaluator.
33263327
/// </summary>
33273328
public ExpressionEvaluator Evaluator { get; }
3329+
3330+
/// <summary>
3331+
/// In the case where generic types are specified with &lt;&gt;
3332+
/// This list contains all specified Types.
3333+
/// </summary>
3334+
public List<Type> GenericTypes { get; }
33283335
}
33293336

33303337
public class FunctionEvaluationEventArg : EventArgs
33313338
{
33323339
private readonly Func<string, object> evaluateFunc = null;
33333340

3334-
public FunctionEvaluationEventArg(string name, Func<string, object> evaluateFunc, List<string> args = null, ExpressionEvaluator evaluator = null, object onInstance = null)
3341+
public FunctionEvaluationEventArg(string name, Func<string, object> evaluateFunc, List<string> args = null, ExpressionEvaluator evaluator = null, object onInstance = null, List<Type> genericTypes = null)
33353342
{
33363343
Name = name;
33373344
Args = args ?? new List<string>();
33383345
this.evaluateFunc = evaluateFunc;
33393346
This = onInstance;
33403347
Evaluator = evaluator;
3348+
GenericTypes = genericTypes ?? new List<Type>();
33413349
}
33423350

33433351
/// <summary>
@@ -3401,7 +3409,7 @@ public object Value
34013409
public bool FunctionReturnedValue { get; set; } = false;
34023410

34033411
/// <summary>
3404-
/// In the case of on the fly instance method definition the instance of the object on which this Function is called.
3412+
/// In the case of on the fly instance method definition the instance of the object on which this method (function) is called.
34053413
/// Otherwise is set to null.
34063414
/// </summary>
34073415
public object This { get; } = null;
@@ -3410,6 +3418,12 @@ public object Value
34103418
/// A reference on the current expression evaluator.
34113419
/// </summary>
34123420
public ExpressionEvaluator Evaluator { get; }
3421+
3422+
/// <summary>
3423+
/// In the case where generic types are specified with &lt;&gt;
3424+
/// This list contains all specified Types.
3425+
/// </summary>
3426+
public List<Type> GenericTypes { get; }
34133427
}
34143428

34153429
#endregion

0 commit comments

Comments
 (0)