/// <summary>
        /// Register for Sink Validator for FluentValidation
        /// </summary>
        /// <param name="registrar"></param>
        /// <param name="typeOfValidator"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IFluentValidationRegistrar AndForFluentValidator(this IWaitForMessageValidationRegistrar registrar, Type typeOfValidator)
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.AndForCustomValidator(FluentValidator.By(typeOfValidator)));
        }
        /// <summary>
        /// Add DataAnnotation support <br />
        /// 添加对数据注解的支持
        /// </summary>
        /// <param name="registrar"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IFluentValidationRegistrar AndForDataAnnotationSupport(this IWaitForMessageValidationRegistrar registrar)
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.AndForCustomValidator <DataAnnotationValidator>());
        }
        /// <summary>
        /// Register for Sink Validator for FluentValidation
        /// </summary>
        /// <param name="registrar"></param>
        /// <param name="validator"></param>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TVal"></typeparam>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IFluentValidationRegistrar AndForFluentValidator <T, TVal>(this IWaitForMessageValidationRegistrar <T, TVal> registrar, FluentValidation.IValidator validator)
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.AndForCustomValidator(FluentValidator.By(validator)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Register for Sink Validator for FluentValidation
        /// </summary>
        /// <param name="registrar"></param>
        /// <typeparam name="TValidator"></typeparam>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IFluentValidationRegistrar AndForFluentValidator <TValidator>(this IWaitForMessageValidationRegistrar registrar)
            where TValidator : class, FluentValidation.IValidator, new()
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.AndForCustomValidator <FluentValidator <TValidator> >());
        }