public void AddDomain(ValidationDomain domain)
        {
            lock (locker)
            {
                if (Domains == null)
                {
                    Domains = new List <ValidationDomain>();
                }

                Domains.Add(domain);
            }
        }
示例#2
0
        public void Valid(object entity)
        {
            CoreValidator    cv     = new CoreValidator();
            ValidationDomain domain = cv.GetDomainByEntityType(entity.GetType());

            if (domain == null)
            {
                return;
            }

            PropertyInfo property = null;

            foreach (ValidationRule rule in domain.Rules)
            {
                property = entity.GetType().GetProperty(rule.Property);
                rule.SetEntity(entity);

                ValidationEngine engine = new ValidationEngine(rule, property);
                engine.RunValidation();
            }
        }