I am in the process of extending a solution based on MVC 3.
Basically, The solution consists of an MVC 3 project along with some class library projects to manage Business/Data Access.
I'm trying to use MEF to make the application plugin-based. for example, I have a UserManager
class in the dll project and I have defined my plugins as follows:
[ImportMany]public List<IUserHooks> Plugins {get; set;}
foreach (var plugin in Plugins)
{
Plugin.DoTheJob();
}
As you can see, the class is separated from MVC project and controllers. The list is defined my UserManager
class.
I know the best approach would be to make UserManager
use MEF as well (Probably initialize it in controller's ctor like public MainController(IUserManager UserManager)
), But since I just want to add plugin support to the solution, and not writing from scratch, I prefer the fastest shortcut.
How should I define my MEF container
object to be able to use it in my class library. Is it necessary to make MVC application using MEF as well? I'd prefer the approach where minimum modification would be necessary to the MVC application.