/// <summary> /// Query rules. /// /// If RuleSet is null, then returns null. /// </summary> /// <param name="filterCriteria"></param> /// <returns></returns> /// <exception cref="Exception">Wrapped error</exception> public IPluralRulesEnumerable Query(PluralRuleInfo filterCriteria) { if (filterCriteria.RuleSet == null) { return(null); } ResultLine line = GetRules(filterCriteria.RuleSet); if (line.Error != null) { throw new Exception(line.Error.Message, line.Error); } if (line.Rules == null) { return(null); } if (line.Rules is IPluralRulesQueryable queryable) { // Set RuleSet to null return(queryable.Query(filterCriteria.ChangeRuleSet(null))); } return(null); }
/// <summary> /// Try to resolve ruleset and evaluate number. /// </summary> /// <param name="subset"></param> /// <param name="number"></param> /// <returns></returns> /// <exception cref="Exception">On wrapped error</exception> public IPluralRule[] Evaluate(PluralRuleInfo subset, IPluralNumber number) { if (subset.RuleSet != null) { ResultLine line = GetRules(subset.RuleSet); if (line.Error != null) { throw new Exception(line.Error.Message, line.Error); } if (line.Rules is IPluralRulesEvaluatable eval) { // Set RuleSet to null return(eval.Evaluate(subset.ChangeRuleSet(null), number)); } } return(null); }