IDependencyResolver是否反模式? [英] Is IDependencyResolver an anti-pattern?

查看:139
本文介绍了IDependencyResolver是否反模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些架构更改设计为旧版ASP.NET应用程序。我原型化了一些模仿ASP.NET MVC的IDependencyResolver的依赖解析类。我不会发布,因为它是几乎相同的界面,但在其他自然语言。

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 IDependencyResolver. I won't post because it is pretty much the same interface, but in other natural language.

我想到它可能被认为是服务位置,反过来通常(在某些情况下不完全)被谴责支持依赖注入。然而,我找不到任何关于使用ASP.NET MVC依赖解析实现的建议。

I figured out it might be considered Service Location, which in turn is usually (not fully in some cases) condemned in favor of Dependency Injection. Nevertheless, I couldn't find any recommendation against the use of the ASP.NET MVC's dependency resolution implementation.

ASP.NET MVC的IDependencyResolver是否被认为是反模式?这是一件坏事吗?

Is the ASP.NET MVC's IDependencyResolver considered an anti-pattern? Is it a bad thing?

推荐答案

如果你看看签名,你会看到它只是一个服务定位器和另一个名字。 服务定位器是一种反模式,我认为关系是可转移的,所以我认为 IDependencyResolver是一个反模式

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.

除此之外,界面也是因为没有Release方法而被破坏

这篇关于IDependencyResolver是否反模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆