microsoft managed extensibility framework
TRANSCRIPT
![Page 1: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/1.jpg)
Binu BhasuranMicrosoft MVP Visual C#
Facebook http://facebook.com/codeno47
Blog http://proxdev.com/
![Page 2: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/2.jpg)
The Managed Extensibility Framework or MEF is a library for creating lightweight, extensible applications. It allows application developers to discover and use extensions with no configuration required. It also lets extension developers easily encapsulate code and avoid fragile hard dependencies. MEF not only allows extensions to be reused within applications, but across applications as well.
![Page 3: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/3.jpg)
Instead of this explicit registration of available components, MEF provides a way to discover them implicitly, via composition.
MEF model requires no hard dependency on a particular application assembly, it allows extensions to be reused from application to application.
![Page 4: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/4.jpg)
MEF is an integral part of the .NET Framework 4, and is available wherever the .NET Framework is used. You can use MEF in your client applications, whether they use Windows Forms, WPF, or any other technology, or in server applications that use ASP.NET.
![Page 5: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/5.jpg)
private Program(){
//An aggregate catalog that combines multiple catalogsvar catalog = new AggregateCatalog();//Adds all the parts found in the same assembly as the Program classcatalog.Catalogs.Add(new AssemblyCatalog(typeof(Program).Assembly));
//Create the CompositionContainer with the parts in the catalog_container = new CompositionContainer(catalog);
//Fill the imports of this objecttry{
this._container.ComposeParts(this);}catch (CompositionException compositionException){
Console.WriteLine(compositionException.ToString());}
}
![Page 6: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/6.jpg)
[Import(typeof(ICalculator))]
public ICalculator calculator;
[Export(typeof(ICalculator))]
class MySimpleCalculator : ICalculator
{
}
[Import(typeof(ICalculator))] public ICalculator calculator;
![Page 7: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/7.jpg)
[ImportMany]
IEnumerable<Lazy<IOperation, IOperationData>> operations;
[Import(typeof(ICalculator))] public ICalculator calculator;
![Page 8: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/8.jpg)
![Page 9: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/9.jpg)
http://msdn.microsoft.com/en-us/library/ms730214.aspx
![Page 10: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/10.jpg)
![Page 11: Microsoft Managed Extensibility Framework](https://reader038.vdocuments.us/reader038/viewer/2022100519/55a209e81a28ab90368b45e4/html5/thumbnails/11.jpg)