Thursday, May 03, 2012

From Zero to MEF'tastic... (Or Dummies Guide To MEF Or Learn to MEF in 21 [or less] Pages)

CodeProject - From Zero to Proficient with MEF

"Learn how to go from being an absolute beginner in the Managed Extensibility Framework to being an advanced user.


Why is it that when we look for a new laptop, we look at the types of ports it has?Not only do we put up with these holes in the sides of our new laptops, we complain if there aren’t enough of them.The answer, of course, is that these ports allow us to extend our laptop.We can add a second monitor, an external hard drive, or a number of other devices.This doesn’t mean that the original laptop is inferior; it just means that different use cases lend themselves to different configurations.So why is it that -  we insist on making applications without “ports”?

In .NET 4.0, Microsoft provided us with the Managed Extensibility Framework (MEF).This framework allows us to easily create extensibility points (ports) in our applications.The most obvious use for this is for plug-ins.You could allow a customer to create their own menu items just like they can do in Microsoft Word or Visual Studio.However, there are other uses for MEF as well.For example, if you expect business rules might be changed or expanded in the future (that never happens, right?), you could use MEF to make this process simple.I’ll show you how below.

Target Audience

When I first started learning how to use MEF, there were a number of resources that helped me.I found practical articles that showed me how to use the framework in a real application and I found technical articles that explained certain features in great length.What I never seemed to find was that one article that was both practical and in-depth.I ended up going from source to source, picking bits and pieces from each.

This article is intended to be that in-depth look at what MEF in a practical manner.I will attempt to walk you through MEF from start to finish.Along the way I will build example applications so you can see exactly how each feature works.For those of you who are familiar with MEF, this article is broken up by feature so that you can quickly get to just the area you need help with.



I thought this a great article for anyone who's interesting in learning about MEF...

No comments: