简体   繁体   中英

What excatly should we understand, when talking about 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM