/// <summary>
 /// Initializes a new instance of the <see cref="FluentValidatorToCatelValidatorAdapter"/> class.
 /// </summary>
 /// <param name="validatorType">
 /// The validator type.
 /// </param>
 private FluentValidatorToCatelValidatorAdapter(Type validatorType)
 {
     _validator = (IValidator)Activator.CreateInstance(validatorType);
     if (!validatorType.TryGetAttribute(out _validatorDescriptionAttribute))
     {
         _validatorDescriptionAttribute = new ValidatorDescriptionAttribute(validatorType.Name);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FluentValidatorToCatelValidatorAdapter"/> class.
        /// </summary>
        /// <param name="validatorType">
        /// The validator type.
        /// </param>
        private FluentValidatorToCatelValidatorAdapter(Type validatorType)
        {
            ConstructorInfo constructorInfo = validatorType.GetConstructor(new Type[] { });

            if (constructorInfo != null)
            {
                _validator = (IValidator)constructorInfo.Invoke(new object[] { });
            }

            if (!AttributeHelper.TryGetAttribute(validatorType, out _validatorDescriptionAttribute))
            {
                _validatorDescriptionAttribute = new ValidatorDescriptionAttribute(validatorType.Name);
            }
        }