Hello guys, Thanks for reading.
I'm using Unity framework to implement dependency injection in my app (ASP.Net MVC). Sometimes there are some cyclic dependencies among services that I want to avoid.
So I'm looking for solutions : )
My case
well lets imagine 3 services ServiceSally, ServiceJoe, ServiceJudy
ServiceSally depends on ServiceJoe
ServiceJoe depends on ServiceJudy
ServiceJudy depends on ServiceSally (<< That is kind of weird isn't it?)
So if you instance ServiceSally, she will need ServiceJoe to be injected, and ServiceJoe will need ServiceJudy and.... BANG!... ServiceJudy will need ServiceSally starting an endless cycle -and very sad love triangle-.
How could I solve this cyclic-loveTriangle case? : /
UPDATE:
My first solution: The LazyJoe
What about to use a wrapper around the services references to delay the injection until they are used?
What do you think?