0

Given a process dependency definition as per below, how would I code the dynamic Boolean logic (condition stored in string field, such as “S1 and S2 or S3”) to calculate the resulting Boolean output.

So if the logic for the below configuration was “((S1 and S2) or (S1 and S3))” And the Boolean outputs of process S1 = false, S2 = true and S3 = true, the result will be false.

Dictionary<string, bool> variables = new Dictionary<string, bool>
{
    {"{P1}", false },
    {"{P2}", true },
    {"{P3}", true },
};
string formulaTemplate = "(({P1} and {P2}) or ({P1} and {P3}))";
bool result = SomeFunction(formulaTemplate, variables);

What would be in SomeFunction?

shabos
  • 108
  • 2
  • 9

0 Answers0