Q:

How can I automatically register all my fluent validators with Unity?

Right now I've got my validators hooked up and building in my app, but every time we add a new validator we need to manually go into our Unity configuration and register the type. I'd like to do this automatically, much like this blog post describes doing with StructureMap, only for Unity instead.
Right now I've got something like this:
    // in global.asax.cs
    protected void Application_Start(Object sender, EventArgs e)
    {
        // some irrelevant registrations (area registrations, route config, etc)

        var container = new UnityContainer();
        UnityConfig.RegisterComponents(container);
        FluentValidationModelValidatorProvider.Configure(c => c.ValidatorFactory = new UnityValidatorFactory(container));
    }

public class UnityValidatorFactory : ValidatorFactoryBase
{
    private readonly IUnityContainer container;

    public UnityValidatorFactory(IUnityContainer container)
    {
        this.container = container;
    }

    public override IValidator CreateInstance(Type validatorType)
    {
        if (container.IsRegistered(validatorType))
        {
            return container.Resolve(validatorType) as IValidator;
        }

        return null;
    }
}

public static class UnityConfig
{
    public static void RegisterComponents(IUnityContainer container)
    {
        container.RegisterTypes(
            AllClasses.FromAssemblies(
                Assembly.GetAssembly(typeof (UnityConfig)),
            WithMappings.FromMatchingInterface, WithName.Default);

        RegisterValidators(container);

        DependencyResolver.SetResolver(new UnityDependencyResolver(container));
    }

    private static void RegisterValidators(IUnityContainer container)
    {
        container.RegisterType<IValidator<MyFirstViewModel>, MyFirstViewModelValidator>();           
        container.RegisterType<IValidator<MySecondViewModel>, MySecondViewModelValidator>();                                   
    }
 }

What I have is working, but I have to keep adding registrations to RegisterValidators() every time a new validator is created. Is there a way I can set this up to automatically detect and register all validators?

A:

This turned out to be pretty easy once I figured out what I was doing, which maybe explains why Googling for the answer was yielding no results. I rewrote RegisterValidators as follows:
private static void RegisterValidators(IUnityContainer container)
{
        var validators = AssemblyScanner.FindValidatorsInAssemblyContaining<OneOfMyValidators>();
        validators.ForEach(validator => container.RegisterType(validator.InterfaceType, validator.ValidatorType));
}

