@@ -746,7 +746,6 @@ public ExpressionEvaluator(Dictionary<string, object> variables) : this()
746
746
#region Main evaluate methods (Expressions and scripts ==> public)
747
747
748
748
private bool inScript = false ;
749
-
750
749
751
750
/// <summary>
752
751
/// Evaluate a script (multiple expressions separated by semicolon)
@@ -1570,7 +1569,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
1570
1569
}
1571
1570
else
1572
1571
{
1573
- FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg ( varFuncName , Evaluate , funcArgs , obj ) ;
1572
+ FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg ( varFuncName , Evaluate , funcArgs , this , obj ) ;
1574
1573
1575
1574
EvaluateFunction ? . Invoke ( this , functionEvaluationEventArg ) ;
1576
1575
@@ -1665,7 +1664,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
1665
1664
}
1666
1665
else
1667
1666
{
1668
- FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg ( varFuncName , Evaluate , funcArgs ) ;
1667
+ FunctionEvaluationEventArg functionEvaluationEventArg = new FunctionEvaluationEventArg ( varFuncName , Evaluate , funcArgs , this ) ;
1669
1668
1670
1669
EvaluateFunction ? . Invoke ( this , functionEvaluationEventArg ) ;
1671
1670
@@ -1762,7 +1761,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
1762
1761
}
1763
1762
else
1764
1763
{
1765
- VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg ( varFuncName , obj ) ;
1764
+ VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg ( varFuncName , this , obj ) ;
1766
1765
1767
1766
EvaluateVariable ? . Invoke ( this , variableEvaluationEventArg ) ;
1768
1767
@@ -1867,7 +1866,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
1867
1866
}
1868
1867
else
1869
1868
{
1870
- VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg ( varFuncName ) ;
1869
+ VariableEvaluationEventArg variableEvaluationEventArg = new VariableEvaluationEventArg ( varFuncName , this ) ;
1871
1870
1872
1871
EvaluateVariable ? . Invoke ( this , variableEvaluationEventArg ) ;
1873
1872
@@ -3024,10 +3023,11 @@ public class VariableEvaluationEventArg : EventArgs
3024
3023
/// Constructor of the VariableEvaluationEventArg
3025
3024
/// </summary>
3026
3025
/// <param name="name">The name of the variable to Evaluate</param>
3027
- public VariableEvaluationEventArg ( string name , object onInstance = null )
3026
+ public VariableEvaluationEventArg ( string name , ExpressionEvaluator evaluator = null , object onInstance = null )
3028
3027
{
3029
3028
Name = name ;
3030
3029
This = onInstance ;
3030
+ Evaluator = evaluator ;
3031
3031
}
3032
3032
3033
3033
/// <summary>
@@ -3060,18 +3060,24 @@ public object Value
3060
3060
/// Otherwise is set to null.
3061
3061
/// </summary>
3062
3062
public object This { get ; private set ; } = null ;
3063
+
3064
+ /// <summary>
3065
+ /// A reference on the current expression evaluator.
3066
+ /// </summary>
3067
+ public ExpressionEvaluator Evaluator { get ; private set ; }
3063
3068
}
3064
3069
3065
3070
public class FunctionEvaluationEventArg : EventArgs
3066
3071
{
3067
3072
private readonly Func < string , object > evaluateFunc = null ;
3068
3073
3069
- public FunctionEvaluationEventArg ( string name , Func < string , object > evaluateFunc , List < string > args = null , object onInstance = null )
3074
+ public FunctionEvaluationEventArg ( string name , Func < string , object > evaluateFunc , List < string > args = null , ExpressionEvaluator evaluator = null , object onInstance = null )
3070
3075
{
3071
3076
Name = name ;
3072
3077
Args = args ?? new List < string > ( ) ;
3073
3078
this . evaluateFunc = evaluateFunc ;
3074
3079
This = onInstance ;
3080
+ Evaluator = evaluator ;
3075
3081
}
3076
3082
3077
3083
/// <summary>
@@ -3139,6 +3145,11 @@ public object Value
3139
3145
/// Otherwise is set to null.
3140
3146
/// </summary>
3141
3147
public object This { get ; private set ; } = null ;
3148
+
3149
+ /// <summary>
3150
+ /// A reference on the current expression evaluator.
3151
+ /// </summary>
3152
+ public ExpressionEvaluator Evaluator { get ; private set ; }
3142
3153
}
3143
3154
3144
3155
#endregion
0 commit comments