Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Studio 2010 and.NET Framework 4 Training Workshop.

Similar presentations


Presentation on theme: "Visual Studio 2010 and.NET Framework 4 Training Workshop."— Presentation transcript:

1 Visual Studio 2010 and.NET Framework 4 Training Workshop

2 Presentation Outline (hidden slide): Technical Level: 300 Intended Audience: Developers & Architects Objectives (what do you want the audience to take away): Understand why and where MEF would be used Understand how MEF is used Presentation Outline: What is extensibility? Where does MEF fit? MEF Basics (Import/Export/Container/Catalogs) MEF Intermediate Topics Lifetime Scoping

3 A Lap Around Managed Extensibility Framework Name Title Organization Email

4 Objectives Understand why and where MEF would be used Understand how MEF is used

5 A MEF-ified Application

6 Managed Extensibility Framework? The Managed Extensibility Framework (MEF) is a new library in the.NET Framework that enables greater reuse of applications and components. Using MEF,.NET applications can make the shift from being statically compiled to dynamically composed

7 What is “Extensibility”? In software engineering, extensibility is a systemic measure of the ability to extend a system and the level of effort required to implement the extension.

8 Open/Closed Principle Software entities should be open for extension, but closed for modification.

9 KnownUnknown VS.

10 MEF ABCs

11 Application built of parts…

12 Using MEF is as simple as Import and Export

13 Part, enter stage left… Part A public class SimpleMortgageCalculator : IMortgageCalculator { public ILogger Logger { get; set; } public float Calculate() { Logger.Log("Calculating Mortgage"); return...; }

14 Imports are Contracts a part needs… Part A public class SimpleMortgageCalculator : IMortgageCalculator { [Import(typeof(ILogger))] public ILogger Logger { get; set; } public float Calculate() { Logger.Log("Calculating Mortgage"); return...; } Import

15 Exports are Contracts a part offers… Part A [Export(typeof(IMortgageCalculator))] public class SimpleMortgageCalculator : IMortgageCalculator { [Import(typeof(ILogger))] public ILogger Logger { get; set; } public float Calculate() { Logger.Log("Calculating Mortgage"); return...; } Export

16 Container is the Match Maker Container

17 Catalogs provide Parts Container Catalog

18 Catalogs provide Parts Container Catalog TypeCatalog AssemblyCatalog DirectoryCatalog AggregatingCatalog

19 Hello, MEF!

20 Parts can be lazy… Part B Export Export [Import(typeof(ILogger))] public ILogger Export Logger { get; set; }

21 Lifetime Container Part A Part B [CompositionOptions(CreationPolicy=CreationPolicy.NonShared)] [CompositionOptions(CreationPolicy=CreationPolicy.Shared)] Shared Non-Shared On Export [Import(RequiredCreationPolicy=CreationPolicy.NonShared)] [Import(RequiredCreationPolicy=CreationPolicy.Shared)] On Import

22 Export Defaults Custom Logger Default Logger Export Order Manager Import [Import(typeof(ILogger)] public MortgageCalculator (ILogger logger) { }

23 Scoping Child Container Parent Container Catalog

24

25 ImperativeDeclarative What How The importance of declarative

26 The importance of discovery Think of a Phonebook…


Download ppt "Visual Studio 2010 and.NET Framework 4 Training Workshop."

Similar presentations


Ads by Google