Pablo Galiano : VS 10 beta 1 Exporting MEF parts from a VS Package (part 3)

Subscriptions

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

News

Subscribe to Pablo Galiano by Email

Post Categories

VS 10 beta 1 Exporting MEF parts from a VS Package (part 3)

***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***

 

This is the final part of this post series. I will show how to get the available exports.

To get the available exports I will use a command under the Tools menu:

image

The menu callback get the first registered IMessagingService export and calls the display message method:

private void MenuItemCallback(object sender, EventArgs e)
{
    var componentModel = base.GetService(typeof(SComponentModel)) as IComponentModel;
    var messaging = componentModel.GetExtensions<IMessagingService>().FirstOrDefault();

    messaging.DisplayMessage("Hello MEF");
}

 

image

 

Couple of points:

  • The SComponentModel service is used to get the available extensions
  • The GetExtension method calls the GlobalCompositionContainer, which find all availables <TExport> in the list of containers that are maintaned by the VsExportProviderService class

 

Pablo

posted on Friday, July 10, 2009 11:09 AM by pga

# re: VS 10 beta 1 Exporting MEF parts from a VS Package (part 3) @ Monday, November 09, 2009 2:22 PM

Pablo,
Thanks for posting this MEF template. I've updated it for VS 2010 Beta 2. Would you be interested in posting the updated version in your blog?

My email address is:
Dwight dot Fowler at Quest dot Com

Dwight Fowler