I have many of the following types:
public class XDatabase : INHibernateDatabase
{
public XDatabase(DatabaseConfiguration) { ... }
}
// etc...
and I'm setting up StructureMap like so:
var container = new Container(x =>
{
x.Scan(scanner =>
{
scanner.Assembly("Model.Persistence");
scanner.AddAllTypesOf<INHibernateDatabase>();
});
// The following will be generated from the app.config ConnectionStrings
x.For<DatabaseConfiguration>()
.Add(new DatabaseConfiguration("something"))
.Named("XDatabase");
// etc....
});
container.GetAllInstances<INHibernateDatabase>();
Obviously this will not work because I have multiple instances (and no default) for DatabaseConfiguration and StructureMap doesn't know which one to choose for which INHibernateDatabase instance.
How can I tell StructureMap to use a convention so that it always picks the DatabaseConnnection instance based on a naming convention?