Hi,
My application is able to start without a database connection, how do I handle this with IoC and constructor injection?
Example:
public class ApplicationShellPresenter(IRepository repository, IView view)
{
}
When IRepository in this case will be constructed an exception will be thrown due to underlaying DAL cannot find config/file, wrong username/password etc. etc.
With this in mind I came to the conclusion that I cannot inject the repository in the constructor OR inject anything that eventually along the line have IRepository as dependency.
I need to start without IRepository dependency and when the user have made the correct database settings, register the IRepository in the container. But then I have already left the composition root.
Anyone got any idéa how to solve this?
Edit:
My problem was not really a IoC/Constructor injection - problem but rather a design flaw in our underlaying DAL.
Our DAL is constructing itself upon creation. And thats why that design didn't work because I couldn't construct a IRepository dependency without constructing our DAL-engine.
My simple solution was to wrap our DAL so it didn't construct itself upon creation.