Is IDependencyResolver an anti-pattern?

后端 未结 2 1568
忘掉有多难
忘掉有多难 2020-11-30 03:34

I am designing some architectural changes into a legacy ASP.NET application. I prototyped some classes for dependency resolution that mimic the ASP.NET MVC\'s IDependencyRes

相关标签:
2条回答
  • 2020-11-30 03:50

    If you look at the signature you will see that it's just a Service Locator with another name. Service Locator is an anti-pattern and I consider the relationship transitive, so I consider IDependencyResolver an anti-pattern.

    Apart from that, the interface is also broken because it has no Release method.

    0 讨论(0)
  • 2020-11-30 03:56

    I don't believe so... You can inject any IoC you want into ASP.NET MVC, which seems like a pretty good pattern to me.

    Here's a blog post about injecting Unity into ASP.NET MVC 3.

    0 讨论(0)
提交回复
热议问题