I have a situtaiton where I read the bussiness logic and replace the variables with actual values and then I need to evaluate it to get result. I am currently using bcParser to do it and it works just fine for all the logic which is written like excel format.
The curve ball thrown at me is that, the if condition will not be like excel if(cond, true, false)
rather it will be like C# where the if (cond) { true; } else { false;}
, this makes more sense and easy to maintain. Since I replace all the variables with value before hand, all I have to do is evaluate it. Currently I am solving this problem by exporting the logic to c# methods and using reflection I am evaluating it and it also works.
I am wondering is there any other option, I do not want to write code for each if condition and would like to evaluate it on the run time. I was wondering if I should able to create a token parser of some sort and call C# native expression evalution and perform the calculation. I haven't gone into understanding expresion trees, it seems it is possible with that approach. before I go there, I would like to know is it possible at all? Thanks,