public virtual IRuleExpressionGroup CreateExpressionGroup(RuleSetEntity ruleSet, IRuleVisitor visitor) { if (ruleSet.Scope != visitor.Scope) { // TODO: ErrHandling (ruleSet is for a different scope) return(null); } var group = visitor.VisitRuleSet(ruleSet); var expressions = ruleSet.Rules .Select(x => CreateExpression(x, visitor)) .Where(x => x != null) .ToArray(); group.AddExpressions(expressions); return(group); }
public virtual async Task <IRuleExpressionGroup> CreateExpressionGroupAsync(RuleSetEntity ruleSet, IRuleVisitor visitor, bool includeHidden = false) { if (ruleSet.Scope != visitor.Scope) { throw new SmartException($"Differing rule scope {ruleSet.Scope}. Expected {visitor.Scope}."); } if (!includeHidden && !ruleSet.IsActive) { return(null); } var group = visitor.VisitRuleSet(ruleSet); var expressions = await ruleSet.Rules .SelectAsync(x => CreateExpression(x, visitor)) .Where(x => x != null) .AsyncToArray(); group.AddExpressions(expressions); return(group); }
private async Task <IRuleExpressionGroup> CreateExpressionGroup(RuleSetEntity ruleSet, RuleEntity refRule, IRuleVisitor visitor) { if (ruleSet.Scope != visitor.Scope) { // TODO: ErrHandling (ruleSet is for a different scope) return(null); } var group = visitor.VisitRuleSet(ruleSet); if (refRule != null) { group.RefRuleId = refRule.Id; } var expressions = await ruleSet.Rules .SelectAsync(x => CreateExpression(x, visitor)) .Where(x => x != null) .AsyncToArray(); group.AddExpressions(expressions); return(group); }