Esempio n. 1
0
 public SqlFileProcessor(IRuleVisitor ruleVisitor, IPluginHandler pluginHandler, IReporter reporter, IFileSystem fileSystem)
 {
     this.ruleVisitor   = ruleVisitor;
     this.pluginHandler = pluginHandler;
     this.reporter      = reporter;
     this.fileSystem    = fileSystem;
 }
Esempio n. 2
0
 public SqlFileProcessor(IRuleVisitor ruleVisitor, IPluginHandler pluginHandler, IReporter reporter, IFileSystem fileSystem)
 {
     _ruleVisitor   = ruleVisitor;
     _pluginHandler = pluginHandler;
     _reporter      = reporter;
     _fileSystem    = fileSystem;
 }
Esempio n. 3
0
 public SqlFileProcessor(IRuleVisitor ruleVisitor, IPluginHandler pluginHandler, IReporter reporter, IFileSystem fileSystem)
 {
     this.ruleVisitor    = ruleVisitor;
     this.pluginHandler  = pluginHandler;
     this.reporter       = reporter;
     this.fileSystem     = fileSystem;
     ruleExceptionFinder = new RuleExceptionFinder();
 }
Esempio n. 4
0
        private IRuleExpression CreateExpression(RuleEntity ruleEntity, IRuleVisitor visitor)
        {
            if (!ruleEntity.IsGroup)
            {
                return(visitor.VisitRule(ruleEntity));
            }

            // It's a group, do recursive call
            var group = CreateExpressionGroup(ruleEntity.Value.Convert <int>(), visitor);

            group.RefRuleId = ruleEntity.Id;

            return(group);
        }
Esempio n. 5
0
        private async Task <IRuleExpression> CreateExpression(RuleEntity ruleEntity, IRuleVisitor visitor)
        {
            if (!ruleEntity.IsGroup)
            {
                return(await visitor.VisitRuleAsync(ruleEntity));
            }

            // It's a group, do recursive call.
            var group = await CreateExpressionGroupAsync(ruleEntity.Value.Convert <int>(), visitor);

            if (group != null)
            {
                group.RefRuleId = ruleEntity.Id;
            }

            return(group);
        }
Esempio n. 6
0
        public IRuleExpressionGroup CreateExpressionGroup(int ruleSetId, IRuleVisitor visitor)
        {
            if (ruleSetId <= 0)
            {
                return(null);
            }

            // TODO: prevent stack overflow > check if nested groups reference each other.

            var ruleSet = _storage.GetCachedRuleSet(ruleSetId);

            if (ruleSet == null)
            {
                // TODO: ErrHandling (???)
                return(null);
            }

            return(CreateExpressionGroup(ruleSet, visitor));
        }
Esempio n. 7
0
 public override TResult Accept <TResult, TContext>(
     IRuleVisitor <TResult, TContext> visitor,
     TContext environment)
 {
     return(visitor.Visit(this, environment));
 }
Esempio n. 8
0
 public SqlFileProcessor(IRuleVisitor ruleVisitor, IBaseReporter reporter, IFileSystem fileSystem)
 {
     _ruleVisitor = ruleVisitor;
     _reporter    = reporter;
     _fileSystem  = fileSystem;
 }
Esempio n. 9
0
 public SqlFileProcessor(IRuleVisitor ruleVisitor, IBaseReporter reporter)
     : this(ruleVisitor, reporter, new FileSystem())
 {
 }
 public TargetGroupFilterDescriptor(IRuleFactory ruleFactory, IRuleVisitor ruleVisitor)
     : base(x => true)
 {
     _ruleFactory = ruleFactory;
     _ruleVisitor = new WeakReference <IRuleVisitor>(ruleVisitor);
 }
Esempio n. 11
0
 public abstract TResult Accept <TResult, TContext>(IRuleVisitor <TResult, TContext> visitor, TContext environment)
     where TContext : IEnvironment;
Esempio n. 12
0
        private 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 = ruleSet.Rules
                              .Select(x => CreateExpression(x, visitor))
                              .Where(x => x != null)
                              .ToArray();

            group.AddExpressions(expressions);

            return(group);
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        public async Task <IRuleExpressionGroup> CreateExpressionGroupAsync(int ruleSetId, IRuleVisitor visitor, bool includeHidden = false)
        {
            if (ruleSetId <= 0)
            {
                return(null);
            }

            // TODO: prevent stack overflow > check if nested groups reference each other.

            var ruleSet = await _db.RuleSets
                          .AsNoTracking()
                          .Include(x => x.Rules)
                          .FirstOrDefaultAsync(x => x.Id == ruleSetId);

            if (ruleSet == null)
            {
                // TODO: ErrHandling (???)
                return(null);
            }

            return(await CreateExpressionGroupAsync(ruleSet, visitor, includeHidden));
        }
Esempio n. 15
0
 public TargetGroupFilterDescriptor(IRuleService ruleService, IRuleVisitor ruleVisitor)
     : base(x => true)
 {
     _ruleService = ruleService;
     _ruleVisitor = new WeakReference <IRuleVisitor>(ruleVisitor);
 }