c# - Where is the best place to put a WindsorContainer and avoid circular project references? -
I use CastleWindsor as a D framework for new layers / projects, with a large current solution is. I'm currently trying to implement some new functionality in a layer / project that has no previous DI in place but I'm having "circular refernce" problems coming up time.
Looking at a solution like this ...
- MyCompany.Core - Includes CastleWindsorConfiguration
- MyCompany.BusinessLayer - includes entities; Business logic
- MyCompany.Data - NHibernate mapping & amp; Are included;
- MyCompany.Web - fron end / display
- MyCompany.Emails - NonA functionality presenting BusinessLayer supplement
- MyCompany.Web - fron end / display
There are quite a few businessLayer supplimentry projects / layers
I do not add the CastleWindsor container email project in a reference core to MyCompany.Core in MyCompany.Email so it can be configured / mapped reference You can do the following ...
_windsorContainer.Register (Component.For & lt; IEMailPoolHandler & gt; () ImplementedBy (typeof (EMailPo OlHandler) LifeStyle.PerWebRequest ..);
But then I will have to resolve this dependency in an email project with something like ...
Private IEMailPoolHandler EMailPoolHandler {get myCompany Core. WindsorContainer.Resolve & LT; IEMailPoolHandler & gt; (); }}
And here I get a circular reference error. Actually I can not reference the core because it references the email.
So, the question really is what is the best way to handle such a situation and where should I want my CastleWindsor container? Or is it okay to do more than one? For example, in each project?
You should put it in a web page. I believe this is a project that has real application-control life and overall configuration - which should be configured, immediately and resolved with the container.
Then you should - if possible - in the e-mail project, in the sections, the email handler or email plus handler or e-mail (CTOR or setter, automatically or manually) inject from the container Do not reach.
Comments
Post a Comment