Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "How and When to Use MEF: Too Much Is Never Enough"— Presentation transcript:

1 How and When to Use MEF: Too Much Is Never Enough
Tech Ed North America 2010 5/4/2019 8:35 PM SESSION CODE: DEV304 How and When to Use MEF: Too Much Is Never Enough Jon Flanders Title MCW Technologies © 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.

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 Tech Ed North America 2010 Name Title Company
5/4/2019 8:35 PM MEF in action Name Title Company DEMO © 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.

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

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

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

8 Widget1 Import it. Import “HelloMEF.Message”
[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 Main Page Import it. ImportMany UserControl
[Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<UserControl> { get;set; } Main Page UserControl ImportMany

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

11 Tech Ed North America 2010 Name Title Company
5/4/2019 8:35 PM MEF in an application Name Title Company DEMO © 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.

12 Resources Learning www.microsoft.com/teched www.microsoft.com/learning
Tech Ed North America 2010 5/4/2019 8:35 PM Resources Learning Sessions On-Demand & Community Microsoft Certification & Training Resources Resources for IT Professionals Resources for Developers © 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.

13 Related Content Interactive Sessions
Tech Ed North America 2010 5/4/2019 8:35 PM 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: Advanced Hands-on Labs DEV06-HOL | Introduction to Managed Extensibility Framework © 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.

14 Complete an evaluation on CommNet and enter to win!
Tech Ed North America 2010 5/4/2019 8:35 PM Complete an evaluation on CommNet and enter to win! © 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.

15 Tech Ed North America 2010 5/4/2019 8:35 PM
© 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. © 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 Tech Ed North America 2010 5/4/2019 8:35 PM
© 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.


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

Similar presentations


Ads by Google