public void Evaluate() { if (!IsValid()) { throw new Exception($"Evaluation of predicate has failed. Missing value {LeftTerm.Id}."); } if (Evaluated) { return; } try { var operatorType = Type.GetType($"Reasoning.Core.Models.Operators.{Enum.GetName(typeof(OperatorType), Operator)}, Reasoning.Core"); var operatorInstance = (IOperator)Activator.CreateInstance(operatorType); Result = operatorInstance.Compare(LeftTerm.GetValue(), RightTerm.GetValue()); Evaluated = true; } catch (Exception ex) { throw new Exception($"Unknown operator instance of predicate", ex); } }
public bool IsValid() { return(!LeftTerm.IsEmpty() && !RightTerm.IsEmpty()); }
} // constructor protected override bool BoolOperator() { return(LeftTerm.Calculate() || RightTerm.Calculate()); } // BoolOperator