SlideShare a Scribd company logo
1 of 31
MANAGED EXTENSIBILITY FRAMEWORK (MEF)
LarryNung
AGENDA
What is MEF
Architecture & Concept
Requirement
How to use
Demo
Reference
Q & A
WHAT IS MEF
WHAT IS MEF
 A library for creating lightweight, extensible applications.
 Discover and use extensions with no configuration required.
 Easily encapsulate code.
 Avoid fragile hard dependencies.
ARCHITECTURE & CONCEPT
ARCHITECTURE & CONCEPT
Import
Export
Part
CompositionContainer
Catalog
ARCHITECTURE & CONCEPT
REQUIREMENT
REQUIREMENT
 Assembly
 .NET 3.5+
 Silverlight 3.0+
 Reference
 System.ComponentModel.Composition.dll
 Namespace
 using System.ComponentModel.Composition;
HOW TO USE
HOW TO USE
HOW TO USE
Step3: Compose Import & Export
Step2: Decorate ExportAttribute
Step1: Decorate ImportAttribute
COMPOSE PARTS
private void Compose()
{
var catalog = new TypeCatalog(this.GetType());
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
COMPOSE PARTS
private void Compose()
{
var
catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecu
tingAssembly());
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
COMPOSE PARTS
private void Compose()
{
var catalog = new DirectoryCatalog(Environment.CurrentDirectory,
"*.dll");
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
COMPOSE PARTS
private void Compose()
{
var catalog = new ApplicationCatalog();
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
COMPOSE PARTS
private void Compose()
{
var
assemblyCatalog = new AssemblyCatalog(System.Reflection.Assembly.GetEx
ecutingAssembly());
var directoryCatalog = new DirectoryCatalog(Environment.CurrentDirectory,
"*.dll");
var catalog = new AggregateCatalog (assemblyCatalog, directoryCatalog);
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
IMPORT & EXPORT
[Import]
string message;
...
[Export]
public string Message
{
get { return "Test..."; }
}
...
IMPORT & EXPORT
[Import(“Message”)]
string message;
...
[Export(“Message”)]
public string Message
{
get { return "Test..."; }
}
…
[Export(typeof(IConfigInfo))]
public class MyClass : IConfigInfo {…
}
[Import(typeof(IConfigInfo))]
object _port1;
[Import(typeof(IConfigInfo))]
IConfigInfo _port1;
[Import(typeof(IConfigInfo))]
Lazy<IConfigInfo> _port1;
IMPORT & EXPORT
[InheritedExport(typeof(IRule))]
public interface IRule
public class RuleOne : IRule {…}
public class RuleTwo : IRule {…}
[ImportMany(typeof(IRule))]
List<IRule> _rules;
[ImportMany(typeof(IRule))]
IRule[] _rules;
[ImportMany(typeof(IRule))]
IEnumerable<IRule> _rules;
[ImportMany(typeof(IRule))]
IEnumerable<Lazy<IRule>> _rule
s;
IMPORT & EXPORT
public class MyClass
{
[ImportingConstructor]
public MyClass([Import(typeof(I
Rule))] IRule myRule)
{
_myRule = myRule;
}
}
[Export,
PartCreationPolicy(CreationPolicy.
Any)]
public class MyClass {…}
[Import]
MyClass _port1;
[Import]
MyClass _port2;
DEMO
DEMO
namespace PlugIn.Core
{
public interface IHost {
IEnumerable<IModule> Modules { get; set; }
}
}
DEMO
namespace PlugIn.Core
{
[InheritedExport] public interface IModule
{
String Name { get; }
IHost Host { get; set; }
void Execute();
}
}
DEMO
namespace Host {
public partial class MainForm : Form, IHost {
...
[ImportMany] public IEnumerable<IModule> Modules { get; set; }
public MainForm() {
InitializeComponent();
var catalog = new DirectoryCatalog(Environment.CurrentDirectory, "*.dll");
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
foreach (IModule module in Modules) {
module.Host = this;
模組MToolStripMenuItem.DropDownItems.Add(module.Name, null,
Module_Click).Tag = module;
}
}
...
}
}
DEMO
REFERENCE
27
REFERENCE
 [C#]MEF開發系列 - Managed Extensibility Framework(MEF)的概念與
簡介 - Level Up- 點部落
 http://www.dotblogs.com.tw/larrynung/archive/2012/12/11/85576.aspx?fid=72
390
 Managed Extensibility Framework - Home
 http://mef.codeplex.com/
 Managed Extensibility Framework - Wikipedia, the free encyclopedia
 http://en.wikipedia.org/wiki/Managed_Extensibility_Framework
REFERENCE
 Managed Extensibility Framework - Building Composable Apps
in .NET 4 with the Managed Extensibility Framework
 https://msdn.microsoft.com/en-us/magazine/ee291628.aspx
 [VS2010 Online]Managed Extensibility Framework in Visual Studio
2010 -- (1) - Response.Write("Hello LOLOTA")- 點部落
 http://www.dotblogs.com.tw/lolota/archive/2010/03/03/13860.aspx
 Managed Extensibility Framework (MEF)
 https://msdn.microsoft.com/zh-tw/library/dd460648(v=vs.110).aspx
Q&A
30
QUESTION & ANSWER
31

More Related Content

Similar to Managed Extensibility Framework (MEF) Guide

Extending the Enterprise with MEF
Extending the Enterprise with MEFExtending the Enterprise with MEF
Extending the Enterprise with MEFBrian Ritchie
 
Meetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationMeetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationThibault Even
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesSami Mut
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS DevelopmentJussi Pohjolainen
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to GriffonJames Williams
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonCodemotion
 
Unbundling the JavaScript module bundler - Codemotion Rome 2018
Unbundling the JavaScript module bundler - Codemotion Rome 2018Unbundling the JavaScript module bundler - Codemotion Rome 2018
Unbundling the JavaScript module bundler - Codemotion Rome 2018Luciano Mammino
 
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...Codemotion
 
Making Steaks from Sacred Cows
Making Steaks from Sacred CowsMaking Steaks from Sacred Cows
Making Steaks from Sacred CowsKevlin Henney
 
Cassandra UDF and Materialized Views
Cassandra UDF and Materialized ViewsCassandra UDF and Materialized Views
Cassandra UDF and Materialized ViewsDuyhai Doan
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling FrameworkAjay K
 
Navigating the wild seas of es6 modules
Navigating the wild seas of es6 modulesNavigating the wild seas of es6 modules
Navigating the wild seas of es6 modulesGil Tayar
 
Delivering High Quality Elixir Code using Gitlab
Delivering High Quality Elixir Code using GitlabDelivering High Quality Elixir Code using Gitlab
Delivering High Quality Elixir Code using GitlabTonny Adhi Sabastian
 

Similar to Managed Extensibility Framework (MEF) Guide (20)

What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Extending the Enterprise with MEF
Extending the Enterprise with MEFExtending the Enterprise with MEF
Extending the Enterprise with MEF
 
Meetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationMeetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son application
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slides
 
Pragmatic Swift
Pragmatic SwiftPragmatic Swift
Pragmatic Swift
 
Quick Start to iOS Development
Quick Start to iOS DevelopmentQuick Start to iOS Development
Quick Start to iOS Development
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
L04 Software Design Examples
L04 Software Design ExamplesL04 Software Design Examples
L04 Software Design Examples
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - Warburton
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
Unbundling the JavaScript module bundler - Codemotion Rome 2018
Unbundling the JavaScript module bundler - Codemotion Rome 2018Unbundling the JavaScript module bundler - Codemotion Rome 2018
Unbundling the JavaScript module bundler - Codemotion Rome 2018
 
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...
Unbundling the JavaScript module bundler - Luciano Mammino - Codemotion Rome ...
 
Making Steaks from Sacred Cows
Making Steaks from Sacred CowsMaking Steaks from Sacred Cows
Making Steaks from Sacred Cows
 
Cassandra UDF and Materialized Views
Cassandra UDF and Materialized ViewsCassandra UDF and Materialized Views
Cassandra UDF and Materialized Views
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling Framework
 
Navigating the wild seas of es6 modules
Navigating the wild seas of es6 modulesNavigating the wild seas of es6 modules
Navigating the wild seas of es6 modules
 
MEF
MEFMEF
MEF
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Delivering High Quality Elixir Code using Gitlab
Delivering High Quality Elixir Code using GitlabDelivering High Quality Elixir Code using Gitlab
Delivering High Quality Elixir Code using Gitlab
 

More from Larry Nung

Ansible - simple it automation
Ansible - simple it automationAnsible - simple it automation
Ansible - simple it automationLarry Nung
 
sonarwhal - a linting tool for the web
sonarwhal - a linting tool for the websonarwhal - a linting tool for the web
sonarwhal - a linting tool for the webLarry Nung
 
LiteDB - A .NET NoSQL Document Store in a single data file
LiteDB - A .NET NoSQL Document Store in a single data fileLiteDB - A .NET NoSQL Document Store in a single data file
LiteDB - A .NET NoSQL Document Store in a single data fileLarry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 8
PL/SQL & SQL CODING GUIDELINES – Part 8PL/SQL & SQL CODING GUIDELINES – Part 8
PL/SQL & SQL CODING GUIDELINES – Part 8Larry Nung
 
MessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization formatMessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization formatLarry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 7
PL/SQL & SQL CODING GUIDELINES – Part 7PL/SQL & SQL CODING GUIDELINES – Part 7
PL/SQL & SQL CODING GUIDELINES – Part 7Larry Nung
 
BenchmarkDotNet - Powerful .NET library for benchmarking
BenchmarkDotNet  - Powerful .NET library for benchmarkingBenchmarkDotNet  - Powerful .NET library for benchmarking
BenchmarkDotNet - Powerful .NET library for benchmarkingLarry Nung
 
PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6Larry Nung
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualityLarry Nung
 
Visual studio 2017
Visual studio 2017Visual studio 2017
Visual studio 2017Larry Nung
 
Web deploy command line
Web deploy command lineWeb deploy command line
Web deploy command lineLarry Nung
 
Topshelf - An easy service hosting framework for building Windows services us...
Topshelf - An easy service hosting framework for building Windows services us...Topshelf - An easy service hosting framework for building Windows services us...
Topshelf - An easy service hosting framework for building Windows services us...Larry Nung
 
Common.logging
Common.loggingCommon.logging
Common.loggingLarry Nung
 
protobuf-net - Protocol Buffers library for idiomatic .NET
protobuf-net - Protocol Buffers library for idiomatic .NETprotobuf-net - Protocol Buffers library for idiomatic .NET
protobuf-net - Protocol Buffers library for idiomatic .NETLarry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 5
PL/SQL & SQL CODING GUIDELINES – Part 5PL/SQL & SQL CODING GUIDELINES – Part 5
PL/SQL & SQL CODING GUIDELINES – Part 5Larry Nung
 
Regular expression
Regular expressionRegular expression
Regular expressionLarry Nung
 
PL/SQL & SQL CODING GUIDELINES – Part 4
PL/SQL & SQL CODING GUIDELINES – Part 4PL/SQL & SQL CODING GUIDELINES – Part 4
PL/SQL & SQL CODING GUIDELINES – Part 4Larry Nung
 
Fx.configuration
Fx.configurationFx.configuration
Fx.configurationLarry Nung
 

More from Larry Nung (20)

Ansible - simple it automation
Ansible - simple it automationAnsible - simple it automation
Ansible - simple it automation
 
sonarwhal - a linting tool for the web
sonarwhal - a linting tool for the websonarwhal - a linting tool for the web
sonarwhal - a linting tool for the web
 
LiteDB - A .NET NoSQL Document Store in a single data file
LiteDB - A .NET NoSQL Document Store in a single data fileLiteDB - A .NET NoSQL Document Store in a single data file
LiteDB - A .NET NoSQL Document Store in a single data file
 
PL/SQL & SQL CODING GUIDELINES – Part 8
PL/SQL & SQL CODING GUIDELINES – Part 8PL/SQL & SQL CODING GUIDELINES – Part 8
PL/SQL & SQL CODING GUIDELINES – Part 8
 
MessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization formatMessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization format
 
PL/SQL & SQL CODING GUIDELINES – Part 7
PL/SQL & SQL CODING GUIDELINES – Part 7PL/SQL & SQL CODING GUIDELINES – Part 7
PL/SQL & SQL CODING GUIDELINES – Part 7
 
BenchmarkDotNet - Powerful .NET library for benchmarking
BenchmarkDotNet  - Powerful .NET library for benchmarkingBenchmarkDotNet  - Powerful .NET library for benchmarking
BenchmarkDotNet - Powerful .NET library for benchmarking
 
PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code Quality
 
Visual studio 2017
Visual studio 2017Visual studio 2017
Visual studio 2017
 
Web deploy command line
Web deploy command lineWeb deploy command line
Web deploy command line
 
Web deploy
Web deployWeb deploy
Web deploy
 
SikuliX
SikuliXSikuliX
SikuliX
 
Topshelf - An easy service hosting framework for building Windows services us...
Topshelf - An easy service hosting framework for building Windows services us...Topshelf - An easy service hosting framework for building Windows services us...
Topshelf - An easy service hosting framework for building Windows services us...
 
Common.logging
Common.loggingCommon.logging
Common.logging
 
protobuf-net - Protocol Buffers library for idiomatic .NET
protobuf-net - Protocol Buffers library for idiomatic .NETprotobuf-net - Protocol Buffers library for idiomatic .NET
protobuf-net - Protocol Buffers library for idiomatic .NET
 
PL/SQL & SQL CODING GUIDELINES – Part 5
PL/SQL & SQL CODING GUIDELINES – Part 5PL/SQL & SQL CODING GUIDELINES – Part 5
PL/SQL & SQL CODING GUIDELINES – Part 5
 
Regular expression
Regular expressionRegular expression
Regular expression
 
PL/SQL & SQL CODING GUIDELINES – Part 4
PL/SQL & SQL CODING GUIDELINES – Part 4PL/SQL & SQL CODING GUIDELINES – Part 4
PL/SQL & SQL CODING GUIDELINES – Part 4
 
Fx.configuration
Fx.configurationFx.configuration
Fx.configuration
 

Recently uploaded

VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Centuryrwgiffor
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdfRenandantas16
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 

Recently uploaded (20)

VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 

Managed Extensibility Framework (MEF) Guide

  • 2. AGENDA What is MEF Architecture & Concept Requirement How to use Demo Reference Q & A
  • 4. WHAT IS MEF  A library for creating lightweight, extensible applications.  Discover and use extensions with no configuration required.  Easily encapsulate code.  Avoid fragile hard dependencies.
  • 9. REQUIREMENT  Assembly  .NET 3.5+  Silverlight 3.0+  Reference  System.ComponentModel.Composition.dll  Namespace  using System.ComponentModel.Composition;
  • 12. HOW TO USE Step3: Compose Import & Export Step2: Decorate ExportAttribute Step1: Decorate ImportAttribute
  • 13. COMPOSE PARTS private void Compose() { var catalog = new TypeCatalog(this.GetType()); var container = new CompositionContainer(catalog); container.ComposeParts(this); }
  • 14. COMPOSE PARTS private void Compose() { var catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecu tingAssembly()); var container = new CompositionContainer(catalog); container.ComposeParts(this); }
  • 15. COMPOSE PARTS private void Compose() { var catalog = new DirectoryCatalog(Environment.CurrentDirectory, "*.dll"); var container = new CompositionContainer(catalog); container.ComposeParts(this); }
  • 16. COMPOSE PARTS private void Compose() { var catalog = new ApplicationCatalog(); var container = new CompositionContainer(catalog); container.ComposeParts(this); }
  • 17. COMPOSE PARTS private void Compose() { var assemblyCatalog = new AssemblyCatalog(System.Reflection.Assembly.GetEx ecutingAssembly()); var directoryCatalog = new DirectoryCatalog(Environment.CurrentDirectory, "*.dll"); var catalog = new AggregateCatalog (assemblyCatalog, directoryCatalog); var container = new CompositionContainer(catalog); container.ComposeParts(this); }
  • 18. IMPORT & EXPORT [Import] string message; ... [Export] public string Message { get { return "Test..."; } } ...
  • 19. IMPORT & EXPORT [Import(“Message”)] string message; ... [Export(“Message”)] public string Message { get { return "Test..."; } } … [Export(typeof(IConfigInfo))] public class MyClass : IConfigInfo {… } [Import(typeof(IConfigInfo))] object _port1; [Import(typeof(IConfigInfo))] IConfigInfo _port1; [Import(typeof(IConfigInfo))] Lazy<IConfigInfo> _port1;
  • 20. IMPORT & EXPORT [InheritedExport(typeof(IRule))] public interface IRule public class RuleOne : IRule {…} public class RuleTwo : IRule {…} [ImportMany(typeof(IRule))] List<IRule> _rules; [ImportMany(typeof(IRule))] IRule[] _rules; [ImportMany(typeof(IRule))] IEnumerable<IRule> _rules; [ImportMany(typeof(IRule))] IEnumerable<Lazy<IRule>> _rule s;
  • 21. IMPORT & EXPORT public class MyClass { [ImportingConstructor] public MyClass([Import(typeof(I Rule))] IRule myRule) { _myRule = myRule; } } [Export, PartCreationPolicy(CreationPolicy. Any)] public class MyClass {…} [Import] MyClass _port1; [Import] MyClass _port2;
  • 22. DEMO
  • 23. DEMO namespace PlugIn.Core { public interface IHost { IEnumerable<IModule> Modules { get; set; } } }
  • 24. DEMO namespace PlugIn.Core { [InheritedExport] public interface IModule { String Name { get; } IHost Host { get; set; } void Execute(); } }
  • 25. DEMO namespace Host { public partial class MainForm : Form, IHost { ... [ImportMany] public IEnumerable<IModule> Modules { get; set; } public MainForm() { InitializeComponent(); var catalog = new DirectoryCatalog(Environment.CurrentDirectory, "*.dll"); var container = new CompositionContainer(catalog); container.ComposeParts(this); foreach (IModule module in Modules) { module.Host = this; 模組MToolStripMenuItem.DropDownItems.Add(module.Name, null, Module_Click).Tag = module; } } ... } }
  • 26. DEMO
  • 28. REFERENCE  [C#]MEF開發系列 - Managed Extensibility Framework(MEF)的概念與 簡介 - Level Up- 點部落  http://www.dotblogs.com.tw/larrynung/archive/2012/12/11/85576.aspx?fid=72 390  Managed Extensibility Framework - Home  http://mef.codeplex.com/  Managed Extensibility Framework - Wikipedia, the free encyclopedia  http://en.wikipedia.org/wiki/Managed_Extensibility_Framework
  • 29. REFERENCE  Managed Extensibility Framework - Building Composable Apps in .NET 4 with the Managed Extensibility Framework  https://msdn.microsoft.com/en-us/magazine/ee291628.aspx  [VS2010 Online]Managed Extensibility Framework in Visual Studio 2010 -- (1) - Response.Write("Hello LOLOTA")- 點部落  http://www.dotblogs.com.tw/lolota/archive/2010/03/03/13860.aspx  Managed Extensibility Framework (MEF)  https://msdn.microsoft.com/zh-tw/library/dd460648(v=vs.110).aspx

Editor's Notes

  1. Managed Extensibility Framework 或 MEF 是用於建立輕量型可擴充應用程式的程式庫。 它可讓應用程式開發人員無需任何設定,即可探索並使用擴充功能。 它也可讓擴充功能開發人員輕易地封裝程式碼並避免出現不牢固的硬式相依性。 透過 MEF,不僅可在應用程式內重複使用擴充功能,也可跨應用程式重複使用擴充功能。 主要側重在 探索性、擴充性、與可移植性
  2. Composable part 是composable unit,也就是最小的組成單位,可以提供服務給其他組件使用(擴充功能)或是操作其他組件提供的服務(擴充點)。 Export 是指提供的服務,也就是我們所說的擴充功能。透過ExportAttribute來設定。 Import 是指所使用的服務,也就是我們所說的擴充點。透過ImportAttribute來設定。 Composition Container 是組合容器,會去mapping import跟export、組合Composable part。 Catalog 主要是用來探索Composable part用的,可從型別、組件 (Assembly) 或目錄 (Directory)探索到Composable part。