Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public abstract IRuleExpressionGroup VisitRuleSet(RuleSetEntity ruleSet);