Exemplo n.º 1
0
 public void AddRule(Rule rule)
 {
     if (rule.Property != null)
     {
         // we have the list, add our new rule
         GetRulesForProperty(rule.Property, true).Add(rule);
     }
     else
     {
         _typeRules.Add(rule);
     }
 }
Exemplo n.º 2
0
        public void AddRule(IValidationRule rule, RuleMeta meta = null)
        {
            //var internalRule = rule as ValidationRule;
            //if (internalRule == null) throw new NotSupportedException("验证规则必须从 ValidationRule 类型继承。");

            //this.AddRule(internalRule.RuleHandler, null, level, priority);

            //if (parameters != null)
            //{
            //    var properties = TypeDescriptor.GetProperties(parameters);
            //    foreach (PropertyDescriptor propertyDescriptor in properties)
            //    {
            //        object value = propertyDescriptor.GetValue(parameters);
            //        args[propertyDescriptor.Name] = value;
            //    }
            //}

            if (rule == null) throw new ArgumentNullException("rule");

            var innerRule = new Rule(rule);
            innerRule.Meta = meta ?? new RuleMeta();

            Rules.AddRule(innerRule);
        }
Exemplo n.º 3
0
        public void AddRule(IManagedProperty property, IValidationRule rule, RuleMeta meta = null)
        {
            if (property == null) throw new ArgumentNullException("property");
            if (rule == null) throw new ArgumentNullException("rule");

            var innerRule = new Rule(rule);
            innerRule.Property = property;
            innerRule.Meta = meta ?? new RuleMeta();

            Rules.AddRule(innerRule);
        }