예제 #1
0
        public void Include(IValidator <T> rulesToInclude)
        {
            if (rulesToInclude == null)
            {
                throw new ArgumentNullException("Cannot pass null to Include");
            }
            var rule = IncludeRule.Create <T>(rulesToInclude, () => CascadeMode);

            NestedValidators.Add(rule);
        }
예제 #2
0
        public IRuleBuilderInitial <T, TProperty> AddRule <TProperty>(Expression <Func <T, TProperty> > expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("Cannot pass null to AddRule");
            }

            var rule = PropertyRule.Create(expression, () => CascadeMode);

            NestedValidators.Add(rule);

            var ruleBuilder = new RuleBuilder <T, TProperty>(rule, this);

            return(ruleBuilder);
        }
예제 #3
0
        public void ConfigDataAnnotation()
        {
            if (isConfigDataAnnotation == false)
            {
                isConfigDataAnnotation = true;
                if (dataAnnotationValidatiors == null)
                {
                    dataAnnotationValidatiors = new TrackingCollection <IValidationRule>();
                    AddDataAnnotationValidation();
                }

                foreach (var item in dataAnnotationValidatiors)
                {
                    NestedValidators.Add(item);
                }
            }
        }