Exemplo n.º 1
0
        public void ConfigureRule(IExecutable rule)
        {
            if (this.XMLConfig.RuleConfigurations == null)
            {
                return;
            }

            var ruleName   = rule.IsSQLRule() ? rule.Name : rule.GetType().ToString();
            var ruleConfig = this.XMLConfig.RuleConfigurations.Where(r => r.Name == ruleName).FirstOrDefault();

            if (ruleConfig == null) //No rule configuration in config file for the specified rule
            {
                return;
            }

            foreach (IProperty property in rule.GetProperties())
            {
                //Find matching property from config file
                RuleProperty ruleProperty = ruleConfig.Properties.Where(p => p.Name == property.Name).FirstOrDefault();
                if (ruleProperty != null)
                {
                    if (property.isValidPropertyValue(ruleProperty.Value))
                    {
                        property.SetValue(ruleProperty.Value);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public RuleConfiguration(IExecutable rule, bool runRule)
        {
            this.Name    = rule.IsSQLRule() ? rule.Name : rule.GetType().ToString();
            this.RunRule = runRule;

            //Add properties
            this.Properties = new List <RuleProperty>();
            foreach (IProperty property in rule.GetProperties())
            {
                this.Properties.Add(new RuleProperty(property));
            }
        }
Exemplo n.º 3
0
        public bool RunRule(IExecutable rule)
        {
            if (this.XMLConfig.RuleConfigurations != null)
            {
                //Rule names in config file are types names for normal rules, but friendly-name for SQL rules
                var ruleName = rule.IsSQLRule() ? rule.Name : rule.GetType().ToString();

                return(this.XMLConfig.RuleConfigurations.Any(c => c.RunRule == true && c.Name == ruleName));
            }
            else
            {
                return(false);
            }
        }