Esempio n. 1
0
        /// <summary>
        /// Invokes all rule methods associated with
        /// the specified property and any
        /// dependant properties.
        /// </summary>
        /// <param name="propertyName">The name of the property to validate.</param>
        public void CheckRules(string propertyName)
        {
            // get the rules dictionary
            ValidationRulesManager rules = RulesToCheck;

            if (rules != null)
            {
                // get the rules list for this property
                RulesList rulesList = rules.GetRulesForProperty(propertyName, false);
                if (rulesList != null)
                {
                    // get the actual list of rules (sorted by priority)
                    List <IRuleMethod> list = rulesList.GetList(true);
                    if (list != null)
                    {
                        CheckRules(list);
                    }
                    List <string> dependancies = rulesList.GetDependancyList(false);
                    if (dependancies != null)
                    {
                        for (int i = 0; i < dependancies.Count; i++)
                        {
                            string dependantProperty = dependancies[i];
                            CheckRules(rules, dependantProperty);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void CheckRules(ValidationRulesManager rules, string propertyName)
        {
            // get the rules list for this property
            RulesList rulesList = rules.GetRulesForProperty(propertyName, false);

            if (rulesList != null)
            {
                // get the actual list of rules (sorted by priority)
                List <IRuleMethod> list = rulesList.GetList(true);
                if (list != null)
                {
                    CheckRules(list);
                }
            }
        }
        internal RulesList GetRulesForProperty(
            string propertyName,
            bool createList)
        {
            // get the list (if any) from the dictionary
            RulesList list = null;

            if (RulesDictionary.ContainsKey(propertyName))
            {
                list = RulesDictionary[propertyName];
            }

            if (createList && list == null)
            {
                // there is no list for this name - create one
                list = new RulesList();
                RulesDictionary.Add(propertyName, list);
            }
            return(list);
        }