Exemplo n.º 1
0
        public bool Validate(bool forceValidate = false)
        {
            if (!(forceValidate || Condition(Extensions.Target)))
            {
                return(BrokenRule == null);
            }

            RuleDebugger.Info("Validating rule " + Name);

            bool status;

            using (new RuleEvaluationContext(this))
                status = OnValidate();

            if (!status)
            {
                if (BrokenRule == null)
                {
                    OnRuleBroke();
                }
                else
                {
                    UpdateBrokenRule(BrokenRule);
                }
            }
            else if (status && BrokenRule != null)
            {
                OnRuleRepaired();
            }

            RuleDebugger.Info("Validation status: " + (status ? "valid" : "failed"));

            return(status);
        }
Exemplo n.º 2
0
        public bool Validate()
        {
            RuleDebugger.Info("Validating rule " + Name);

            bool status;

            using (new RuleEvaluationContext(this))
                status = OnValidate();

            if (!status && BrokenRule == null)
            {
                OnRuleBroke();
            }
            else if (status && BrokenRule != null)
            {
                OnRuleRepaired();
            }

            RuleDebugger.Info("Validation status: " + (status ? "valid" : "failed"));

            return(status);
        }