Example #1
0
 internal BrokenRule(IRuleMethod rule)
 {
   _ruleName = rule.RuleName;
   _description = rule.RuleArgs.Description;
   _property = rule.RuleArgs.PropertyName;
   _severity = rule.RuleArgs.Severity;
 }
Example #2
0
 internal BrokenRule(IRuleMethod rule)
 {
     _ruleName    = rule.RuleName;
     _description = rule.RuleArgs.Description;
     _property    = rule.RuleArgs.PropertyName;
     _severity    = rule.RuleArgs.Severity;
 }
        internal void Add(IRuleMethod rule)
        {
            Remove(rule);
            IsReadOnly = false;
            BrokenRule item = new BrokenRule(rule);

            IncrementCount(item);
            Add(item);
            IsReadOnly = true;
        }
 internal void Remove(IRuleMethod rule)
 {
     // we loop through using a numeric counter because
     // removing items within a foreach isn't reliable
     IsReadOnly = false;
     for (int index = 0; index < Count; index++)
     {
         if (this[index].RuleName == rule.RuleName)
         {
             DecrementCount(this[index]);
             RemoveAt(index);
             break;
         }
     }
     IsReadOnly = true;
 }
Example #5
0
        /// <summary>
        /// Given a list
        /// containing IRuleMethod objects, this
        /// method executes all those rule methods.
        /// </summary>
        private void CheckRules(List <IRuleMethod> list)
        {
            bool previousRuleBroken = false;
            bool shortCircuited     = false;

            for (int index = 0; index < list.Count; index++)
            {
                IRuleMethod rule = list[index];
                // see if short-circuiting should kick in
                if (!shortCircuited && (previousRuleBroken && rule.Priority > _processThroughPriority))
                {
                    shortCircuited = true;
                }

                if (shortCircuited)
                {
                    // we're short-circuited, so just remove
                    // all remaining broken rule entries
                    BrokenRulesList.Remove(rule);
                }
                else
                {
                    // we're not short-circuited, so check rule
                    if (rule.Invoke(_target))
                    {
                        // the rule is not broken
                        BrokenRulesList.Remove(rule);
                    }
                    else
                    {
                        // the rule is broken
                        BrokenRulesList.Add(rule);
                        if (rule.RuleArgs.Severity == RuleSeverity.Error)
                        {
                            previousRuleBroken = true;
                        }
                    }
                    if (rule.RuleArgs.StopProcessing)
                    {
                        shortCircuited = true;
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Returns an array containing the text descriptions of all
        /// validation rules associated with this object.
        /// </summary>
        /// <returns>String array.</returns>
        /// <remarks></remarks>
        public string[] GetRuleDescriptions()
        {
            List <string>          result = new List <string>();
            ValidationRulesManager rules  = RulesToCheck;

            if (rules != null)
            {
                foreach (KeyValuePair <string, RulesList> de in rules.RulesDictionary)
                {
                    List <IRuleMethod> list = de.Value.GetList(false);
                    for (int i = 0; i < list.Count; i++)
                    {
                        IRuleMethod rule = list[i];
                        result.Add(rule.ToString());
                    }
                }
            }
            return(result.ToArray());
        }
Example #7
0
 public void Add(IRuleMethod item)
 {
   _list.Add(item);
   _sorted = false;
 }
Example #8
0
 public void Add(IRuleMethod item)
 {
     _list.Add(item);
     _sorted = false;
 }