Reputation: 9973
I recently converted from MEF to Unity - for various reasons.
I previously had a IMenuService object in a module that I exported with MEF and imported in other modules. I believe what I have to do with Unity is take the unity container in as a parameter to the constructor of my module, then use that to register the IMenuService , however, I'm not sure how to do this (what argument type? do I have to first register the container in the bootstrapper to import it into the module?)
Also, in MEF there are ModuleDependency attributes to make sure other modules are loaded first... what would be the equivolent in Unity?
EDIT: figured out the IUnityContainer argument... however, still curious about the seconds part... dependencies
Upvotes: 1
Views: 686
Reputation: 3854
as you have figured out, the type you should have your modules depend on to IUnityContainer
. You don't really have to register the container with itself in order to be able to work with it in the modules (while you can do it if you wanted, and to make things clearer). And last, module dependencies are independent from the IoC container you're using, so it should work just fine. You can as well configure the ModuleCatalog
from xaml using:
protected override IModuleCatalog CreateModuleCatalog()
{
return ModuleCatalog.CreateFromXaml(new Uri("catalog.xaml", UriKind.Relative));
}
and in the catalog.xaml
file, you can specify the dependencies using the DependsOn
property of the ModuleInfo
.
hope this helps :)
Upvotes: 1