コード例 #1
0
        /// <summary>Returns the list containing rules for a property. If no list exists one is created and returned.</summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns><see cref="ValidationRulesList"/> for the specified property name.</returns>
        /// <exception cref="ArgumentNullEmptyWhiteSpaceException">Thrown when propertyName is null, empty, or white space.</exception>
        public ValidationRulesList GetRulesForProperty(String propertyName)
        {
            if (String.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentNullEmptyWhiteSpaceException(nameof(propertyName));
            }
            if (this.RulesDictionary.ContainsKey(propertyName))
            {
                return(this.RulesDictionary[propertyName]);
            }

            var validationRulesList = new ValidationRulesList();

            this.RulesDictionary.Add(propertyName, validationRulesList);
            return(validationRulesList);
        }