I am trying to figure out how to use simpleinjector for following situation.
I have a solution with 4 Projects
- Business (Concrete Business Classes)
- Repo (Concrete Repo classes)
- Contract (Only Interfaces)
- API (Composition root)
Business , Repo and Api has direct reference to the Contract.
Contract has Interface for Business and Repo
Business Implements the IBusiness from Contract project and
Repo implements the IRepo from contract project
I don't want the API to have any project reference to Business or Repo project. Those 2 compiled assembly will be pushed to a general location (ie: bin folder on api).
Here is a pic or what I want.
When I look at the documentation for simpleinjector, it asks me to do something like the following
container.Register<IRepo, Repo>();
This assumes the API project has knowledge of the Repo project. It doesn't. API Project only knows about the Contract that has the IRepo and IBusiness interfaces. So my API project will never compile since on the Composition root, while I am Registering the IRepo to Repo, the APi project has no knowledge about the Repo project. API has reference to only the Contract project which only has the interfaces (IBusiness and IRepo). Business and Repo projects are separate from the Contract project and they reference the IBusiness and IRepo Interfaces to create the Business and Repo concrete class.
QUESTION is: How do I do the late binding with SimpleInjector?
In the past, I used ninject and using the ninjectModule, I was able to tell the Business or Repo project If a request from Contract comes for IBusiness or IRepo , it should map that to Business or Repo. I didn't need any reference on my Api to Business concreate class or Repo concrete class.
Can the same be done with the simpleinjector? I don't want to put project reference for Business or Repo in API project.
I am not sure, if I am looking at the right item to achieve this. My problem is understanding this for SimpleInjector.
Please feel free to help.