当谈论MEF时我们到底应该理解什么

发布于 2024-12-01 11:01:41 字数 187 浏览 0 评论 0原文

我已经研究MEF(托管可扩展性框架)两天了。然而,我认为 MEF 无法给我带来我所期望的东西。

我想要一个软件设计:将有核心应用程序,并且应用程序的所有模块都将作为插件完成。例如,在电子商务应用程序中,订单模块、活动模块等都应该作为插件添加。

问题是:我可以在 Asp.NET webform 上使用 MEF 进行这样的设计吗?

I've been researching about MEF(managed extensibility framework) for two days. However, I think MEF can't give me what I expect from it.

I want a software desing that: There will be core application and all modules of the application will be done as plugin. For example, in a e-commerce application order module, campaign module etc all should be added as a plugin.

The question is that: can I make such this design with MEF on Asp.NET webform?

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

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

发布评论

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

评论(1

呢古 2024-12-08 11:01:41

我想要一个软件设计:将有核心应用程序,并且应用程序的所有模块都将作为插件完成

正是 MEF 支持的场景类型。 MEF 是围绕组合未知类型集(MEF 中的部分)这一概念而设计的。这些部分是您的模块和插件。 MEF 负责发现这些部件,并将所有内容连接起来。 MEF 也不会将您限制为单一模型。 MEF 本身是可扩展的,这使得它具有如此强的适应性。

当您将 ASP.NET 与 MEF 结合使用时,您必须考虑应用程序的生命周期取决于其在 IIS 中的可用性。您还必须考虑到 Web 应用程序的运行时模型与桌面应用程序有很大不同。

我花了很多时间研究 MEF 和 ASP.NET(特别是 ASP.NET MVC),这里有一些我的文章的链接:

  1. 使用托管扩展性框架 (MEF) 的模块化 ASP.NET MVC,第一部分
  2. 使用托管扩展性框架 (MEF) 的模块化 ASP.NET MVC这托管扩展性框架 (MEF),第二部分
  3. 使用托管扩展性框架 (MEF) 的模块化 ASP.NET MVC,第三部分
  4. MVC3 和 MEF
  5. MEF 和 WCF 的即插即用服务

我想说,实现 MEF + ASP.NET MVC 集成可能比实现更好的集成更容易对 WebForms 做同样的事情,因为 MVC 的架构是模块化和可扩展的(特别是在 MVC3 中)。 WebForms 您需要考虑页面事件和生命周期,以及如何将它们连接在一起。

如果你用谷歌搜索的话,网上有一些很棒的资源,一些可靠的例子,不错的技巧等,比如 Tim Robert 的文章,标题为 使用 MEF 定义 Web 范围的部件。 StackOverflow 上已经有很多涉及这个主题的问题(及其答案)。

您还可以使用 IoC 容器实现类似的结果,例如 Castle Windsor、Ninject、Autofac 等。

I want a software desing that: There will be core application and all modules of the application will be done as plugin

This is exactly the type of scenario that MEF enables. MEF is designed around the concept of composing an unknown set of types (parts in MEF-speak). These parts are your modules and plugins. MEF takes care of discovery of these parts, and wires everything up. MEF also doesn't limit you to a single model of doing it. MEF is extensible itself which is what makes it so adaptable.

When you combine ASP.NET with MEF, you have to consider the lifetime of an application is governed by its availability in IIS. You also have to consider that the runtime model for a web application is a lot different than that of a desktop application.

I've been spending a lot of time with MEF and ASP.NET (specifically ASP.NET MVC), here are a few links to my articles:

  1. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part One
  2. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Two
  3. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Three
  4. MVC3 and MEF
  5. Plug and Play Services with MEF and WCF

I would say it's probably easier to achieve a nice MEF + ASP.NET MVC integration than to do the same for WebForms, as MVC as be architectured to be modular and extensible (especially in MVC3). WebForms you need to take the page eventing and lifetime into consideration, and how that all plugs together.

There are some great resources around the web if you google, some solid examples, nice tricks etc, like Tim Robert's article entitled Defining Web-scoped parts with MEF. There are also a whole host of questions (with answers) already on StackOverflow that cover this very topic.

You can also achieve similar results using an IoC Container, such as Castle Windsor, Ninject, Autofac etc.

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