Doin’ TechEd – You’re App is so MEF

If you’ve heard anything about the new feature set of Visual Studio 2010 one of the game changing features for any developer is the Built in Extension Manager, this functionally is using MEF. What exactly is MEF? The Managed Extensibility Framework is as Framework for creating loosely-coupled, extensible applications. I am blogging this from the TechEd North America Session, When and Where to use MEF: Too much is never enough.

Where can I find MEF?

No MEF isn’t found in your local dark alley, and you  don’t need to know a guy that knows a guy in order to use MEF. MEF is baked into the .NET framework comes out of the System.ComponentModel.Composition (2.0.5.0 for Silverlight, 4.0 for .NET 4.0) assembly.

Parts of MEF

Catalogs

A Catalog in terms of MEF is a class that contains metadata about your particular application so that it is able to pull in the particular Imports and Exports.

Exports

Exports in MEF are a way of exposing contracts to the framework when a particular class type is needed to be implemented into your application.  This is useful when you need to use multiple implementations of an Interface to cover a particular task, like logging.

[Export[typeof(ILogger)]
public class RedGreenLogger
{
	// Implement Class here
}

Imports

Imports in MEF is a way of stating that a concrete implementation is needed within the application. You will attribute a method with a particular importer when you would like MEF to fill in the blanks with an export or many exports for that particular task.

[ImportMany(typeof(ILogger)]
public List<ILogger>() Executors
{
	// Add Implementation here
}

Containers

A container is a wrapper used to collect the Catalogs at a hi

public void Init(Executor e)
{
	var container = new CompositionContainer(new DirectoryCatalog(Environment.CurrentDirectory));
	container.SatifsyImportsOnce(e);
}

Composition

Composition is the piece of MEF that pulls all the parts of together. This is a call that you need to do explicitly, however depending on the implementation composition can be extremely easy or increasingly more difficult. When using Silverlight you can do this very simply by calling a method and passing the main page into the application and MEF runs automagically.

CompositionContainer.ComposeParts(this);

I can make a Living Application?

Due to the fact that you’re creating an abstracted [loosely-coupled] application, and how MEF can be used to create dynamically loaded components, you have the ability to use MEF to add new features to your application, or add additional functionality to your application without recompiling your application.

Doin’ TechEd – Developer Fundamentals Session

New Capabilities for Visual Studio 2010

Even though Microsoft just Launched Visual Studio 2010, they are constantly going back to create new features. Just launched today is a new set of features for workflow in Visual Studio. You can Download the new Visual Studio Pro Power Tools from Visual Studio Gallery

Some examples of the new Features

  • Hold ctrl – Click : Urls to Code
  • Triple Click : Place Cursor far left
  • Pin Tabs in IDE with Project Based Tab Coloring
  • Search on Add Reference Window (Finally!)

Going Agile in Visual Studio

Scrum Process Templates are available for TFS 2010 so you can start bringing the power of Agile Methodologies into your IDE. This tool gives you ability to outline and organize your projects in a way that works for you. This tool also gives you the ability to get reports on how your project is coming along. To give this tool a test drive, head over to the Visual Studio Gallery and download the TFS Scrum v1.0 beta.

Expression 4 is Available

Released today is the new version of Expression, Expression Studio 4. If you have a MSDN Subscription you are able to download these tools today!

There are a number of new Behaviors available from within the Assets tool menu. These behaviors allow you to enable some additional features in sketch flow without writing any code, like creating more intelligent prototypes.