An update - Welcome to new features from Autofac....
Here is how you register all your validators:
Here is how you register all your validators:
builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
.AsClosedTypesOf(typeof(IValidator<>)).AsImplementedInterfaces()
.InstancePerLifetimeScope();
The factory remains the same... public class ModelValidatorFactory : IValidatorFactory
{
public IValidator GetValidator(Type type)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
return DependencyResolver.Current.GetService(typeof(IValidator<>).MakeGenericType(type)) as IValidator;
}
public IValidator<T> GetValidator<T>()
{
return DependencyResolver.Current.GetService<IValidator<T>>();
}
}