Exemplo n.º 1
0
        protected override RuleSet GetRulesFromTypeCore(Type type)
        {
            var classMapping = new ValidatorEngine().GetClassValidator(type);

            var rules = from member in type.GetMembers()
                        where member.MemberType == MemberTypes.Field || member.MemberType == MemberTypes.Property
                        from constraint in classMapping.GetMemberConstraints(member.Name).OfType<IRuleArgs>()
                        // All NHibernate Validation validators attributes must implement this interface
                        from rule in ConvertToXValRules(constraint)
                        where rule != null
                        select new { MemberName = member.Name, Rule = rule };

            return new RuleSet(rules.ToLookup(x => x.MemberName, x => x.Rule));
        }
Exemplo n.º 2
0
        protected override RuleSet GetRulesFromTypeCore(Type type)
        {
            var classMapping = new ValidatorEngine().GetClassValidator(type);

            var rules = from member in type.GetMembers()
                        where member.MemberType == MemberTypes.Field || member.MemberType == MemberTypes.Property
                        from constraint in classMapping.GetMemberConstraints(member.Name).OfType <IRuleArgs>()

                        // All NHibernate Validation validators attributes must implement this interface
                        from rule in ConvertToXValRules(constraint)
                        where rule != null
                        select new { MemberName = member.Name, Rule = rule };

            return(new RuleSet(rules.ToLookup(x => x.MemberName, x => x.Rule)));
        }