1 / 16

How and When to Use MEF: Too Much Is Never Enough

SESSION CODE: DEV304. How and When to Use MEF: Too Much Is Never Enough . Jon Flanders Title MCW Technologies. Managed Extensibility Framework (MEF). MEF is a framework for creating loosely-coupled, extensible applications This has always been possible with .NET

lana
Download Presentation

How and When to Use MEF: Too Much Is Never Enough

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SESSION CODE: DEV304 How and When to Use MEF: Too Much Is Never Enough Jon Flanders Title MCW Technologies

  2. Managed Extensibility Framework (MEF) • MEF is a framework for creating loosely-coupled, extensible applications • This has always been possible with .NET • Interfaces+classes+dynamic assembly loading • MEF is a standardization of this pattern • Much of Visual Studio 2010 uses MEF • Its extensibility layer relies on it heavily

  3. MEF in a nutshell • MEF centers around three main concepts • Catalog • Exports • Imports • Catalogs contain components that are to be composed • Exports expose “Contracts” • Classes or properties • Imports are properties that require Exported instances • Composition pulls it all together

  4. MEF in action NameTitleCompany DEMO

  5. MEF Basics… Export it. Import it. Composeit.

  6. Export it. [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 UserControl Export

  7. Import it. [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 String Import

  8. Import it. [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import(“HelloMEF.Message”)] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } } Widget1 “HelloMEF.Message” Import

  9. Import it. [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<UserControl> { get;set; } } Main Page UserControl ImportMany

  10. Compose it. PartIntializer: “Compose yourself” public MainPage() { InitializeComponent(); CompositionInitializer.SatisfyImports(this); } MainPage Compose

  11. MEF in an application NameTitleCompany DEMO

  12. Resources Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn

  13. Related Content • Interactive Sessions • DEV05-INT | What's Wrong with My .NET Extensible MEF Application? • Session Type: Interactive Session • Thursday, June 10 | 8:00 AM - 9:15 AM | Rm 347 • Track: Developer Tools, Languages & Frameworks • Speaker(s): Daniel Plaisted • Level: 300 - Advanced • Hands-on Labs • DEV06-HOL | Introduction to Managed Extensibility Framework

  14. Complete an evaluation on CommNet and enter to win!

  15. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

  16. Required Slide

More Related