21
DAVID GIARD MCTS, MCSD, MCSE, MCDBA Principal Consultant, Sogeti www.DavidGiard.com

Managed Extensibility Framework 2010 01

Embed Size (px)

Citation preview

Page 1: Managed Extensibility Framework 2010 01

DAVID GIARD

MCTS, MCSD, MCSE, MCDBAPrincipal Consultant, [email protected]

Page 2: Managed Extensibility Framework 2010 01

MANAGED EXTENSIBILITY FRAMEWORK

Beta 2

Page 3: Managed Extensibility Framework 2010 01

Compile and Deploy

TIGHT COUPLING

DLL

DLL

EXE

Page 4: Managed Extensibility Framework 2010 01

MEF

LOOSE COUPLING WITH MEF

Compile and Deploy

Contract

Contract

ContractContract

DLL

DLL

EXE

DLL

Page 5: Managed Extensibility Framework 2010 01

MANAGED EXTENSIBILITY FRAMEWORK Applications consists of loosely-coupled

components that are discovered and composed at runtime

Page 6: Managed Extensibility Framework 2010 01

ADVANTAGES OF MEF

Loose Coupling Swap Classes at Runtime No Recompile or Redeploy Single Plug-In Architecture

Page 7: Managed Extensibility Framework 2010 01

MEF USAGE SCENARIOS

Empower developers to extend your application without modifying it

Provide extra modules to your application, as needed

Use MEF as an platform ecosystem to manage all parts of your application

Page 8: Managed Extensibility Framework 2010 01

DEMO

MEFApp(Accounting)

G/L

A/R

A/P

Export

GenSetu

p

Modules for Accounting app

Page 9: Managed Extensibility Framework 2010 01

GET STARTED

MEF.CodePlex.com Download and unzip MEF_Beta_2.zip Zip file contains

DLLs Samples Source Code

Page 10: Managed Extensibility Framework 2010 01

DEVELOPER STEPS

Import

Export

Set Reference to System.ComponentModel.Composition.dll

Contract Import Export

Catalogs Composition

Contra

cts

Page 11: Managed Extensibility Framework 2010 01

MEF

CONTRACTS

[Import(“Contract1”)]String SomeThing {get; set;}

[Export(“Contract1”)]Public string SpecialThing {Get {return “A Value”};}

“A Value”

Page 12: Managed Extensibility Framework 2010 01

MEF

CONTRACTS

[Import(“Contract1”)]String SomeThing {get; set;}

[Export(“Contract1”)]Public string MoreSpecialThing {Get {return “A Different Value”};}

“A Different Value”

Page 13: Managed Extensibility Framework 2010 01

MEF

INTERFACE CONTRACTS

[Import(typeof(IFoo))]IFoo SomeFoo {get; set;}

[Export(typeof(IFoo))]public Foo: IFoo{…}

new Foo()

Page 14: Managed Extensibility Framework 2010 01

MEF

INTERFACE CONTRACTS

[ImportMany(typeof(IFoo))]List<IFoo> BunchOfFoos{get; set;}

[Export(typeof(IFoo))]public Foo1: IFoo{…} new Foo1()

[Export(typeof(IFoo))]public Foo2: IFoo{…} new Foo2()

Page 15: Managed Extensibility Framework 2010 01

COMPOSITION

Catalogs TypeCatalog AssemblyCatalog DirectoryCatalog AggregateCatalog PackageCatalog (Silverlight toolkit)

var catalog1 = new DirectoryCatalog(@"c:\MEF\Imports");var container = new CompositionContainer catalog1);container.ComposeParts(this);

Page 16: Managed Extensibility Framework 2010 01

DEMO

Using MEF

Page 17: Managed Extensibility Framework 2010 01

MEF VS DEPENDENCY INJECTION

Page 18: Managed Extensibility Framework 2010 01

RESOURCES http://MEF.codeplex.com http://www.davidgiard.com http://msmvps.com/blogs/kathleen http://blogs.msdn.com/gblock http://tinyurl.com/

TaultyMEFSilverlightVideos NPlus1.org

David Giard, MCTS, MCSD, MCSE, MCDBA

[email protected]

Page 19: Managed Extensibility Framework 2010 01

USER GROUPS

Great Lakes Area .Net User Group Southfield, MI migang.org

Greater Lansing .Net User Group East Lansing, MI glugnet.org

Page 20: Managed Extensibility Framework 2010 01

DAVE’S THOUGHTS

DavidGiard.com TechnologyAndFriends.com

[email protected]

Page 21: Managed Extensibility Framework 2010 01