Dependency Injection with MEF and Unity Pavel Yosifovich Hi-Tech College pavely@hi-tech.co.il http://blogs.microsoft.co.il/blogs/pavely
Agenda Why MEF? MEF Features Why Unity? Unity Features Q & A Summary
MEF Basics DEMO
MEF Basics Parts Catalog Container Export and Import A list of parts The matchmaker Composition MEF Part Export Import MEF Part Export Import
MEF Basics - Catalogs AggregateCatalog DirectoryCatalog AssemblyCatalog TypeCatalog
MEF Features DEMO
More MEF Features [ImportingConstructor] [ImportMany] Creation Policy AllowDefault=true Re-composition Metadata
MEF - Summary MEF is about extensibility through composition Dependency Injection capabilities Not a true IoC container Part of .NET 4 MEF for Silverlight 4 Mostly similar, some Silverlight specific features( e.g. DeploymentCatalog)
Basic Unity DEMO
Unity Basics A true IoC container Registering types Resolving and injecting dependencies Configuration
More Unity Features DEMO
More Unity Features Lifetime management Hierarchical containers Aspect Oriented Programming (AOP) Interception
Questions?
Summary MEF is an extensibility framework Unity is an IoC container Exports & Imports Metadata and Re-composition Unity is an IoC container Type resolution Interception (AOP) Both provide Dependency Injection
Resources MEF on CodePlex Unity on CodePlex http://mef.codeplex.com/ Unity on CodePlex http://unity.codeplex.com/ Microsoft Patterns & Practices http://msdn.microsoft.com/en-us/practices/
משובים ופייסבוק מירב- השלמה