SlideShare a Scribd company logo
1 of 40
Managed Extensibility Framework (MEF) Mohamed Meligy Code: 02F01
Extensibility Extensions
 
[object Object],[object Object]
Web App Stock Quotes Authenticator Error Handler Logger Database This example was created by Jim Weirich in Ruby on his blog. See his original article  http ://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc
 
[object Object],[object Object],[object Object],[object Object]
 
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
DIContainer container = new DIContainer(); container.Register<ILogger, Logger>(); container.Register<IDatabase, Database>(); container.Register<IErrorHandler, ErrorHandler>(); container.Register<IQuotes, StockQuotes>(); container.Register<IAuthenticator, Authenticator>(); container.Register<IWebApp, WebApp>();
 
 
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
 
 
[object Object],[object Object],[object Object],[object Object],2
Application ToolWindow  A ToolWindow  B Contacts Call Support Help File Edit View Tools Help
Application Extension A Extension B Need a  Toolwindow Got a Toolwindow Need Menus Got a Menu Need a MenuService Got a MenuService
 
Windows And Menus With MEF public   interface   IToolWindow  { } public   interface   IMenuService  { }  public   interface   IMenu  { }   public   class   Application { [ Import ] public   IEnumerable < IToolWindow > ToolWindows {  get ;  set ; }   [ Import ] public   IEnumerable < IMenu > Menus {  get ;  set ; } }   [ Export ( typeof ( IMenuService ))] public   class   MenuService  :  IMenuService  { }
Windows And Menus With MEF [ Export ( typeof ( IToolWindow ))] public   class   SomeToolWindow  :  IToolWindow { [ Import ] public   IMenuService  MenuService {  get ;  set ; } }   [ Export ( typeof ( IMenu ))] public   class   SomeMenu  :  IMenu {}  
First, The Composable Part  Part  A
Parts Relate Through Contracts Part  B Part  A
Imports Are Contracts A Part Needs Part  B Import Import
Exports Are Contracts A Part Offers Export Export Part  B
The Container Is The Matchmaker Container
Container Queries Catalogs Catalog Container
Parts Can Load Lazily Part  B Part  A Export <A>
Parts Can Have Different Lifetimes Container Container Part A Singleton Part A Part A Part A Factory
 
 
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Code: 02F01 Eng . [email_address] . com weblogs . asp . net/meligy
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

Similar to Managed Extensibility Framework (MEF)

Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Extending the Enterprise with MEF
Extending the Enterprise with MEFExtending the Enterprise with MEF
Extending the Enterprise with MEFBrian Ritchie
 
Poco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignPoco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignJames Phillips
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodekinfusiondev
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsNuno Caneco
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
FIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE
 
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeBlueFish
 
Real World Asp.Net WebApi Applications
Real World Asp.Net WebApi ApplicationsReal World Asp.Net WebApi Applications
Real World Asp.Net WebApi ApplicationsEffie Arditi
 
Extending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native ModulesExtending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native Modulesomorandi
 
Spring training
Spring trainingSpring training
Spring trainingTechFerry
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
How to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxHow to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxBOSC Tech Labs
 
Whidbey old
Whidbey old Whidbey old
Whidbey old grenaud
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFCBlueFish
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationrtretola
 
DSDP Mobile Tools for Java Webinar
DSDP Mobile Tools for Java WebinarDSDP Mobile Tools for Java Webinar
DSDP Mobile Tools for Java Webinargustavoeliano
 
HTML5 Introduction
HTML5 IntroductionHTML5 Introduction
HTML5 Introductionbeforeach
 

Similar to Managed Extensibility Framework (MEF) (20)

Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Extending the Enterprise with MEF
Extending the Enterprise with MEFExtending the Enterprise with MEF
Extending the Enterprise with MEF
 
Poco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignPoco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class Design
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodek
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
FIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT Agents
 
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes Code
 
Real World Asp.Net WebApi Applications
Real World Asp.Net WebApi ApplicationsReal World Asp.Net WebApi Applications
Real World Asp.Net WebApi Applications
 
Extending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native ModulesExtending Appcelerator Titanium Mobile through Native Modules
Extending Appcelerator Titanium Mobile through Native Modules
 
Spring training
Spring trainingSpring training
Spring training
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
How to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxHow to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptx
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFC
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR application
 
DSDP Mobile Tools for Java Webinar
DSDP Mobile Tools for Java WebinarDSDP Mobile Tools for Java Webinar
DSDP Mobile Tools for Java Webinar
 
HTML5 Introduction
HTML5 IntroductionHTML5 Introduction
HTML5 Introduction
 

More from Mohamed Meligy

DDD Sydney 20111 Razor Session
DDD Sydney 20111 Razor SessionDDD Sydney 20111 Razor Session
DDD Sydney 20111 Razor SessionMohamed Meligy
 
Twitter OAuth With C#/.NET Code
Twitter OAuth With C#/.NET CodeTwitter OAuth With C#/.NET Code
Twitter OAuth With C#/.NET CodeMohamed Meligy
 
Using jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms WorldUsing jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms WorldMohamed Meligy
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design GuidelinesMohamed Meligy
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCMohamed Meligy
 
Design Patterns Via C# 3.0
Design Patterns Via C# 3.0Design Patterns Via C# 3.0
Design Patterns Via C# 3.0Mohamed Meligy
 

More from Mohamed Meligy (8)

NDC Sydney 2018 Ngrx
NDC Sydney 2018   NgrxNDC Sydney 2018   Ngrx
NDC Sydney 2018 Ngrx
 
DDD Sydney 20111 Razor Session
DDD Sydney 20111 Razor SessionDDD Sydney 20111 Razor Session
DDD Sydney 20111 Razor Session
 
Twitter OAuth With C#/.NET Code
Twitter OAuth With C#/.NET CodeTwitter OAuth With C#/.NET Code
Twitter OAuth With C#/.NET Code
 
Using jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms WorldUsing jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms World
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
 
Design Patterns Via C# 3.0
Design Patterns Via C# 3.0Design Patterns Via C# 3.0
Design Patterns Via C# 3.0
 
Scrum For Developers
Scrum For DevelopersScrum For Developers
Scrum For Developers
 

Managed Extensibility Framework (MEF)

  • 1. Managed Extensibility Framework (MEF) Mohamed Meligy Code: 02F01
  • 3.  
  • 4.
  • 5. Web App Stock Quotes Authenticator Error Handler Logger Database This example was created by Jim Weirich in Ruby on his blog. See his original article http ://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc
  • 6.  
  • 7.
  • 8.  
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. DIContainer container = new DIContainer(); container.Register<ILogger, Logger>(); container.Register<IDatabase, Database>(); container.Register<IErrorHandler, ErrorHandler>(); container.Register<IQuotes, StockQuotes>(); container.Register<IAuthenticator, Authenticator>(); container.Register<IWebApp, WebApp>();
  • 16.  
  • 17.  
  • 18.
  • 19.
  • 20.  
  • 21.  
  • 22.
  • 23. Application ToolWindow A ToolWindow B Contacts Call Support Help File Edit View Tools Help
  • 24. Application Extension A Extension B Need a Toolwindow Got a Toolwindow Need Menus Got a Menu Need a MenuService Got a MenuService
  • 25.  
  • 26. Windows And Menus With MEF public interface IToolWindow { } public interface IMenuService { }  public interface IMenu { }   public class Application { [ Import ] public IEnumerable < IToolWindow > ToolWindows { get ; set ; }   [ Import ] public IEnumerable < IMenu > Menus { get ; set ; } }   [ Export ( typeof ( IMenuService ))] public class MenuService : IMenuService { }
  • 27. Windows And Menus With MEF [ Export ( typeof ( IToolWindow ))] public class SomeToolWindow : IToolWindow { [ Import ] public IMenuService MenuService { get ; set ; } }   [ Export ( typeof ( IMenu ))] public class SomeMenu : IMenu {}  
  • 28. First, The Composable Part Part A
  • 29. Parts Relate Through Contracts Part B Part A
  • 30. Imports Are Contracts A Part Needs Part B Import Import
  • 31. Exports Are Contracts A Part Offers Export Export Part B
  • 32. The Container Is The Matchmaker Container
  • 33. Container Queries Catalogs Catalog Container
  • 34. Parts Can Load Lazily Part B Part A Export <A>
  • 35. Parts Can Have Different Lifetimes Container Container Part A Singleton Part A Part A Part A Factory
  • 36.  
  • 37.  
  • 38.
  • 39.
  • 40.