国际奥委会从开始到结束

发布于 2024-08-28 22:57:42 字数 311 浏览 14 评论 0原文

我非常确定 IoC 是我的应用程序的最佳选择。这里有大量关于 SO 的文章甚至问题讨论不同的容器。我今天读了几篇带有部分示例的博客。我个人倾向于从 CommonServiceLocator 和 Unity 作为解决同一问题的两种方法开始——我只需要一堆程序集来从数据库获取数据,我认为这是需要注入到任何地方的数据。

我还没有找到任何真正从头到尾解决问题并提供具体代码示例的网站。例如,我还没有找到一个讨论 IServiceLocator 以及如何实际注册它(或执行任何需要使其为人所知的操作)的文章。

您最喜欢的帖子/文章/SO问题是什么,这些问题可以让菜鸟从头到尾完成实施?

I'm quite sure that IoC is the way to go for my application. There are a ton of articles and even questions here on SO that discuss the different containers. I've read several blogs today with partial examples. I am personally leaning towards starting with the CommonServiceLocator and Unity as two way to solve the same problem -- I just need a bunch of assemblies to get data from a database, which I assume is what needs to be injected everywhere.

I've yet to find any sites that really take a problem from beginning to end, with concrete code examples. For example, I've yet to find one that discusses an IServiceLocator and how to actually register it (or do whatever is required to make it known).

What are your favorite posts / articles / SO questions that can take a noob from start to finish with the implementation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

榕城若虚 2024-09-04 22:57:42

如果您还没有阅读过,我推荐:

(我还建议阅读 ploeh 博客 - Mark 将 DI 写为 。

两者都没有提供端到端的应用程序示例,但它们共同提供了一个坚实的概述,这

对于理解不同类型的依赖注入至关重要(您可能已经阅读过它,基于 你的问题),但在我真正了解如何在现实世界中使用 DI 之前,我确实必须阅读 Hevery 的文章(并且你应该阅读更多 Hevery 的内容或 Mark Seemann 的“服务定位器是一种反模式",如果只是为了了解为什么不应该使用服务定位器!)

最后,我不经常看到明确说明的一件事:您的顶级应用程序是

If you haven't already read them, I recommend:

(I also recommend reading ploeh blog - Mark writes about DI as well as or better than anyone).

Neither provides an end-to-end application example, but together they provide a solid outline.

Fowler's article is critical to understanding the different types of dependency injection (and you may have already read it, based on your question), but I really had to read Hevery's article before I grokked how I'd use DI in the real world. (And you should read more of Hevery's stuff or Mark Seemann's "Service Locator is an Anti-Pattern", if only to understand why you shouldn't use service locator!)

Finally, one thing that I don't often see stated explicitly: your top-level applications are the only things that should reference your dependency injection framework classes.

我只土不豪 2024-09-04 22:57:42

如果您仍然对使用 Unity 感兴趣,那么以下截屏视频值得下载 - Unity IoC 基础知识。虽然最后确实有现实世界的例子,但不幸的是,他完全浏览了它们——尽管有博客文章的链接进一步解释了这些例子,如果有兴趣,你可以按照自己的节奏浏览。

If you're still interested in using Unity, then the following screencast is worth the download - Unity IoC Fundamentals. While it does have real world examples at the end, unfortunately he absolutely flies through them - though there are links to blog posts further explaining the examples which you could go through at your own pace if interested.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文