What is the best design for this issue with IoC and Circular Reference

I will try to explain in a simple way.

I have a solution (C # 4.0) containing 4 projects

  • Framework
  • DAL
  • Domain
  • Webapplication

So my question is:

Is the frame the right place to set up my Unity IoC? I want to configure through code, not using xml, so Framework should know the DAL link, but DAL already knows the Framework.

All my projects will know the Framework, so when will I set up my IoC?

+4
source share
1 answer

Applications must be configured in the Root composition , which is as close as possible to the entry point. In your case, this will be WebApplication. This is a project that should have a link to Unity . None of the other projects should have links to Unity at all.

At the root of the composition, you must follow the Register Resolve Release pattern.

See also this answer - it talks about Ninject instead of Unity, but the concept (and therefore the answer) is the same.

+4
source

Source: https://habr.com/ru/post/1347736/


All Articles