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); }
/// <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); }
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); }
/// <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); }