I primarily use NInject as my IoC container, and is very happy with it - don't want to change that. But some things I want to import using MEF. The thing is, I want the imports to created by the IoC container as the imports can have dependencies to things that I've registered in the NInject IoC.
So, my question is: can I import the type of exports in some way, so I can hand it over to NInject for creation or is there an object factory of some kind that I can override in MEF?
Introduction. The Managed Extensibility Framework (MEF) has solved the common problems encountered when developing enterprise applications. It's a new library introduced in the . NET Framework 4.0, which is essentially an IOC container.
You can waste days evaluating IOC containers. The top ones are quite similar. There is not much in this, but the best ones are StructureMap and AutoFac. At SSW we use Autofac on most projects.
The IoC container constructs an object of the selected class and also injects all the dependency objects via a constructor, a property, or a function at execution time and disposes it at a suitable time. This approach helps to create and manage objects manually.
The IoC container that is also known as a DI Container is a framework for implementing automatic dependency injection very effectively. It manages the complete object creation and its lifetime, as well as it also injects the dependencies into the classes.
Autofac 2.1 integrates pretty well with MEF. See this post by Nicholas Blumhardt about how it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With