120 likes | 211 Views
Experiment: Building an AppMarket using The MEF and .NET 4. Josh Twist Principal Consultant, Microsoft UK www.thejoyofcode.com jtwist@microsoft.com @ joshtwist. About this session. Focus is The MEF Not aiming to cover all the features but apply it to a scenario
E N D
Experiment: Building an AppMarket using The MEF and .NET 4 Josh Twist Principal Consultant, Microsoft UK www.thejoyofcode.com jtwist@microsoft.com@joshtwist
About this session • Focus is The MEF • Not aiming to cover all the features but apply it to a scenario • Heaps to get through so need some Blue Peter ingredients
The experiment • Build an extensible application that can download and run ‘applets’. • Allow the applets to leverage optional services • Create a service that makes applets discoverable with the minimum amount of code
Primers • Dependency Injection (DI) and Inversion of Control (IoC) Containers • The Managed Extensibility Framework
DI/IoC Containers • About the removal of concrete dependencies • Using abstract types (ideally interfaces) • The Container is the FooMaker • Most containers are typically configured via code or XML Foofoo = new Foo(); IFoofoo = FooMaker.GetFoo(); IFoo foo = Container.Resolve<IFoo>(); Container.RegisterType<IFoo, Foo>(); <TypeMapping From="IFoo" To="Foo" />
DI/IoC Containers • Type are registered in a catalog(ue) • But, what if Foo depends on IBar? //constructorpublic Foo(IBar bar)
The MEF • Very similar, it has • A container • Catalogs • Strategic build up of dependencies • But the focus is different… It’s all about runtime discovery baby!
Experiment: the Shell {Binding Applets} {Binding LaunchCommand} {Binding CurrentApplet} {Binding HomeCommand} Home
At last, some code Let the DEMO begin
jtwist@microsoft.com @joshtwist www.thejoyofcode.com Thank you