Wednesday, August 28, 2013

Managed Extensibility Framework

Hi All...
As most of you will definitely be aware of what is MEF and what is Dependency Injection.

MEF supports the Lazy implementation internally. The Lazy type actually wraps around a type and creates the object of the type when the object is actually needed and used.
In MEF, objects once exports are either imported in actual object or imported in Lazy form of Actual object. 

Lazy is actually used when your plugins are heavy and need large amount of memory. Therefore the objects will not be created when you Compose Parts for the Container(this is composition basically composition container) rather than it produce the Lazy implementation of the same and you can defer object creation when it is actually called for. Lets look how it works.

We need to wrap the object that needed to be imported as lazy using Lazy block.

So suppose I have interface 
[Import]
public Maddy Importit { get; set; }