Question about resolving #150
Description
I have a project in which I used Singularity, and it has a very simple setup -|
builder.Register<Configuration>(conf => conf.With(Lifetimes.PerContainer)); builder.Register<IConnectionFactory, ConnectionFactory>();
which is resolved in a final class -
public Service(DatabaseHandler dbHandler, RemoteDatabaseHandler remoteDbHandler, Server server, Publisher publisher, Router router, ServiceMessagePump messagePump, Configuration configuration)
and everything works.
Looking at the documentation, I though that this should also work -
public Service(Func<string, DatabaseHandler> dbHandlerFactory, RemoteDatabaseHandler remoteDbHandler, Server server, Publisher publisher, Router router, ServiceMessagePump messagePump, Configuration configuration)
but this does not work, because Singularity is not able to resolve DatabaseHandler. This is it's constructor which works
public DatabaseHandler(IConnectionFactory factory)
- and I though that if I change it like
public DatabaseHandler(IConnectionFactory factory, string connectionType)
I could resolve it like Func<string, DatabaseHandler>
and then get an instance like DatabaseHandler = dbHandlerFactory("some string...").
Should this work or are my assumptions wrong?
Thanks.