When using Dependency Injection with StructureMap how do I chooose among multiple constructors?
- by Mark Rogers
I'm trying to get structuremap to build Fluent Nhibernate's SessionSource object for some of my intregration tests. The only problem is that Fluent's concrete implementation of ISessionSource (SessionSource) has 3 constructors:
public SessionSource(PersistenceModel model)
{
Initialize(new Configuration().Configure(), model);
}
public SessionSource(IDictionary<string, string> properties, PersistenceModel model)
{
Initialize(new Configuration().AddProperties(properties), model);
}
public SessionSource(FluentConfiguration config)
{
configuration = config.Configuration;
sessionFactory = config.BuildSessionFactory();
dialect = Dialect.GetDialect(configuration.Properties);
}
I've tried configuring my ObjectFactory supplying an argument for the first constructor but it seems like it wants to try the second one.
How do I configure my ObjectFactory so that I can choose the first constructor or perhaps even another one if I decide to use that?