We are using unity as IoC. We came across unique problem. We have created interface called IPlugin. This interface is shared across various third party vendors to develop their own plug in based on this interface. These plug ins then fits into our system. Vendors will provide their plugs in as dll. What we want is , Using unity we want to resolve all assembly’s type which is implemented with IPlugin interface. I came to know that this is achievable via MEF export attribute, I am wondering whether this can be achieved via Unity using some short of extension.
Our code
Public interface IPlugin
{
Void ProcessData();
}
Public class DataProcessor
{
Var pluginList = unityContainer.ResolveAssemblies<IPlugIn>()
/*
There is no such method in unity but what we want is scan all assemblies in bin folder and load all types which are inheriting from IPlugIn
*/
}
Vendor’s assembly
Public class AbcCompanyPlugIn : IPlugin
{
Void ProcessData()
{
// some code
}
}
Public class XyzCompanyPlugIn : IPlugin
{
Void ProcessData()
{
// some code
}
}