private IValidator GetValidator(ValidatorAttribute attribute)
        {
            if (attribute == null || attribute.ValidatorType == null)
            {
                return(null);
            }

            var validator = instanceFactory == null
                                ? cache.GetOrCreateInstance(attribute.ValidatorType)
                                : cache.GetOrCreateInstance(attribute.ValidatorType, instanceFactory);

            return(validator as IValidator);
        }
示例#2
0
        /// <summary>
        /// Gets a validator for the appropriate type.
        /// </summary>
        public virtual IValidator GetValidator(Type type)
        {
            var attribute = type?.FirstAttribute <ValidatorAttribute>();

            if (attribute?.ValidatorType == null)
            {
                return(null);
            }

            return(cache.GetOrCreateInstance(attribute.ValidatorType) as IValidator);
        }
示例#3
0
 public override IValidator GetValidator(Type type)
 {
     if (type != null)
     {
         var attribute = (ValidatorAttribute)Attribute.GetCustomAttribute(type, typeof(ValidatorAttribute));
         if ((attribute != null) && (attribute.ValidatorType != null))
         {
             var instance = m_Cache.GetOrCreateInstance(attribute.ValidatorType,
                                                        x => DependencyResolver.Current.ResolveUnregistered(x));
             return(instance as IValidator);
         }
     }
     return(null);
 }
示例#4
0
        /// <summary>
        /// Gets a validator for the appropriate type.
        /// </summary>
        public virtual IValidator GetValidator(Type type)
        {
            if (type == null)
            {
                return(null);
            }

            var attribute = (ValidatorAttribute)Attribute.GetCustomAttribute(type, typeof(ValidatorAttribute));

            if (attribute == null || attribute.ValidatorType == null)
            {
                return(null);
            }

            return(cache.GetOrCreateInstance(attribute.ValidatorType) as IValidator);
        }