public bool RuleTrue(VariableValueList oVariableValues, Rule RuleToEvaluate) { bool ReturnedValue = false; lock (this) { if (oVariableValues == null || RuleToEvaluate == null) { throw new ArgumentNullException("Error! RuleEvaluator:RuleTrue can not get null argument"); } if (m_bValidateVariables == true) { CheckVariableDeclarationListAndValuesConsistency(oVariableValues); } StrongTypeRulesBase StrongTypeRule; StrongTypeRule = GetStrongTypedRule(RuleToEvaluate); ReturnedValue = StrongTypeRule.RuleTrue(oVariableValues); } return(ReturnedValue); }
// Check that there are no tags names in run-time (meta-tags values) // which name does not exist in the setup-time (meta-tags schema) // Anyway this error will be found when compiling the strong-typed class, // but using this check at this earlier stage can find this problem much // faster protected void CheckVariableDeclarationListAndValuesConsistency(VariableValueList oVariableValues) { foreach (VariableValue oVal in oVariableValues) { if (!m_oGlobalVariablesDeclaration.Contains(oVal.Name)) { throw new TisException("Error! RuleEvaluator:CheckVariableDeclarationListAndValuesConsistency Variable:" + oVal.Name + " is not found in the VariableDeclarationList "); } } }
// this method should be overloaded in the derived class, to implement // the specific rule that this class was designed to evaluate // The long parameter name is to prevent accidental usage as a valid // parameter name public virtual bool RuleTrue(VariableValueList TiS_TagsValueForRuleCalculation_Tis) { if (TiS_TagsValueForRuleCalculation_Tis == null) { throw new ArgumentException("Error! StrongTypeRulesBase:RuleTrue can not get null argument"); } m_TiSVariableValues = TiS_TagsValueForRuleCalculation_Tis; // not relvant - just to match the function signature return(true); }
// UserDefinedFunctions can be null - no user defined functions public StrongTypeRulesBase(object UserDefinedFunctions) { m_UserDefinedFunctions = UserDefinedFunctions; m_TiSVariableValues = null; }