Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Question about resolving #150

Open
high1 opened this issue Nov 22, 2020 · 0 comments
Open

Question about resolving #150

high1 opened this issue Nov 22, 2020 · 0 comments

Comments

@high1
Copy link

high1 commented Nov 22, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant