예제 #1
0
        /// <summary>
        /// Creates the validator for the specified target and ruleset.
        /// </summary>
        /// <param name="targetType">The <see cref="Type"/>to validate.</param>
        /// <param name="ruleset">The ruleset to use when validating</param>
        /// <param name="mainValidatorFactory">Factory to use when building nested validators.</param>
        /// <returns>A <see cref="Validator"/></returns>
        protected internal override Validator InnerCreateValidator(Type targetType, string ruleset, ValidatorFactory mainValidatorFactory)
        {
            ConfigurationValidatorBuilder builder =
                new ConfigurationValidatorBuilder(
                    ValidationSettings.TryGet(ConfigurationSource),
                    MemberAccessValidatorBuilderFactory.Default,
                    mainValidatorFactory);

            return(builder.CreateValidator(targetType, ruleset));
        }
예제 #2
0
        ///<summary>
        ///</summary>
        ///<param name="configurationSource"></param>
        ///<param name="memberAccessValidatorBuilderFactory"></param>
        ///<param name="validatorFactory"></param>
        ///<returns></returns>
        public static ConfigurationValidatorBuilder FromConfiguration(
            IConfigurationSource configurationSource,
            MemberAccessValidatorBuilderFactory memberAccessValidatorBuilderFactory,
            ValidatorFactory validatorFactory)
        {
            var settings = ValidationSettings.TryGet(configurationSource);

            return
                (new ConfigurationValidatorBuilder(
                     settings,
                     memberAccessValidatorBuilderFactory,
                     validatorFactory));
        }
        ///<summary>
        ///</summary>
        ///<param name="configurationSource"></param>
        ///<param name="memberAccessValidatorBuilderFactory"></param>
        ///<param name="validatorFactory"></param>
        ///<returns></returns>
        public static ConfigurationValidatorBuilder FromConfiguration(
            IConfigurationSource configurationSource,
            MemberAccessValidatorBuilderFactory memberAccessValidatorBuilderFactory,
            ValidatorFactory validatorFactory)
        {
            var instrumentationProvider = ValidationInstrumentationProvider.FromConfigurationSource(configurationSource);
            var settings = ValidationSettings.TryGet(configurationSource, instrumentationProvider);

            return
                (new ConfigurationValidatorBuilder(
                     settings,
                     instrumentationProvider,
                     memberAccessValidatorBuilderFactory,
                     validatorFactory));
        }