Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to find which variables were modified during expression evaluation? #165

Open
mercurial-moon opened this issue Oct 27, 2024 · 1 comment
Labels

Comments

@mercurial-moon
Copy link

Hi,

For an expression like
a = b * c
we know that a would be modified after evaluating the expression.
Is there a mechanism in ExpressionEvaluator which tells us that a will/could be modified after evaluating the expression.

ExpressionEvaluator has a PreEvaluateVariable event but that is fired for all variables in the expression, i`m looking to find the variables on the left hand side of the expression.

This could be done in string processing but was hoping if there is a better way where I could have the expression engine to tell me.

@codingseb
Copy link
Owner

Hi @mercurial-moon.
Thanks for your issue.

For now there is no event for variable assignation equivalent to PreEvaluateVariable or EvaluateVariable.
As I do not have so much time to continue developping ExpressionEvaluator I don't know when I could add this.

But for your case, there is maybe an alternative way by inheritance.

using CodingSeb.ExpressionEvaluator;

public class YourEvaluator : ExpressionEvaluator
{
    protected override void AssignVariable(string varName, object value)
    {
        // Do What you want here for pre assignation 
        
        // Here we redo what ExpressionEvaluator would do
        base.AssignVariable(varName,value)

      // Do What you want here for postassignation 
}

I hope it helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants