When bootstrapping StructureMap I've always ever used default instances (as opposed to named instances) and was able to define a simple convention to scan by assemblies to wire up the instances. Without going into the details of the convention itself, I'd bootstrap like this:
assemblies.ForEach(a =>
x.Scan(y =>
{
y.Assembly(a);
y.WithDefaultConventions();
y.Convention<DomainInterfaceNamingConvention>();
}));
Where assemblies is a list of assemblies I put together elsewhere in the initializer and DomainInterfaceNamingConvention is my custom convention for scanning those assemblies to match interfaces with implementations.
This has worked really well for as long as I can remember. However, now I have cause to use named instances. So, for example, I might bootstrap my logger implementation like this:
x.For<Logger>().Use(l => new Log4Net.LoggerImplementation());
x.For<Logger>().Add(l => new Log4Net.LoggerImplementation()).Named("Log4Net");
x.For<Logger>().Add(l => new NLog.LoggerImplementation()).Named("NLog");
So a default is defined, as well as some named instances added in case the code specifically requests one.
But, how can I combine the two? In my example for the named instances the configuration is per-class, while in my example of convention-based instances the configuration is per-assembly. I have a lot of classes in some of my assemblies, and in this particular scenario those classes can come and go fairly frequently. So needing to manually wire up each class instead of just each assembly would be a not insignificant operational headache for development.
Is there a way to have names at the assembly level in convention-based scanning? So, for example, I might have tons of bootstrapped repository instances named "Database" for one assembly, and a ton named "XML" for another assembly, and a ton named "Mock" for another assembly, without having to specify each individual repository (three times, four if you count the default) in the bootstrapper?