C H A P T E R  14

The Managed Extensibility Framework

The Managed Extensibility Framework (MEF) is designed to help you create extensible applications. It can discover loosely coupled components (known as parts) at runtime, and “composes” them together. MEF can provide the following two key benefits to your application:

  • As a simple dependency injection framework, MEF allows parts of your application to be decoupled, with the dependencies resolved at runtime.
  • MEF provides a plug-in framework, helping you to modularize your application and make it extensible.

One of the common uses of MEF in Silverlight applications is to provide a way for you to modularize your application, and have the modules download separately from the “shell application.” This allows the shell application to download quickly, saving the user from having to wait for the entire application to be downloaded before they can start using it.

Although MEF's key focus is on extensibility, it's also often used as a dependency injection framework. MEF is installed with Silverlight as a part of the Silverlight SDK, so it is an obvious choice when there is no need for a more fully fledged dependency injection framework.

images Note Discussion of the concept of dependency injection and the dependency inversion principle is beyond the scope of this book, but in summary, the dependency inversion principle states the following:

• High-level modules should not depend on low-level modules. Both should depend on abstractions.

• Abstractions should not depend upon details. Details should depend upon abstractions.

MEF provides a way for us to decouple parts of our applications to remove dependencies between them, and have the dependencies resolved at runtime.

In this chapter, we'll look at what MEF is, show you how you can get started with using MEF in your Silverlight applications, and get you to the point where you can use MEF to help you modularize your applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset