/// <summary> /// Invokes named rule in a specified rulePointPath. /// </summary> /// <typeparam name="T">Return type</typeparam> /// <param name="rulePointPath">The path of rule point which contains the named rule.</param> /// <param name="ruleName">The name of the rule</param> /// <param name="arguments">The arguments required by this rule</param> /// <returns>The execution result of the named rule, or default(T) if the rule does not exist"/></returns> public T InvokeNamedRule <T>(string rulePointPath, string ruleName, Dictionary <string, object> arguments) { if (String.IsNullOrEmpty(rulePointPath)) { throw new ArgumentNullException("rulePointPath"); // NOXLATE } if (String.IsNullOrEmpty(ruleName)) { throw new ArgumentNullException("ruleName"); // NOXLATE } if (arguments == null) { throw new ArgumentNullException("arguments"); // NOXLATE } RulePoint parentRulePoint = GetRulePoint(rulePointPath); if (parentRulePoint == null) { return(default(T)); } NamedRule namedRule = parentRulePoint.GetNamedRule(ruleName); if (namedRule == null) { return(default(T)); } return(InvokeRule <T>(namedRule, arguments)); }
/// <summary> /// Gets a named rule by a given path. /// </summary> /// <param name="rulePath">The path of the named rule you want to get</param> /// <returns>The named rule if it exists; otherwise, null.</returns> public NamedRule GetNamedRule(string rulePath) { if (String.IsNullOrEmpty(rulePath)) { throw new ArgumentNullException("rulePath"); // NOXLATE } string rulePointPath; string ruleName; if (RulePathHelper.ExtractNamedRulePath(rulePath, out rulePointPath, out ruleName)) { RulePoint theRulePoint = GetRulePoint(rulePointPath); if (theRulePoint != null) { return(theRulePoint.GetNamedRule(ruleName)); } } return(null); }