开发者

Autofac integration into Prism 4

开发者 https://www.devze.com 2023-03-14 21:28 出处:网络
I am swapping out the standard Unity container in Prism 4 and run into a pr开发者_StackOverflow中文版oblem when my modules are initializing. Before I used to get an IUnityContainer injected and this t

I am swapping out the standard Unity container in Prism 4 and run into a pr开发者_StackOverflow中文版oblem when my modules are initializing. Before I used to get an IUnityContainer injected and this then allowed me to register additional types from my module all well and good.

Now I am injecting an AutoFac.IContainer and it does not have the RegisterType methods i need. They are located in the ContainerBuilder class.

So the simple question is how to I register types into my main container from within my modules as they are loaded.

Thanks Craig


The standard Autofac way is building your modules as IModule classes, using builder.RegisterModule to load them into your container as part of the register process.

If you already have a container and need to add registrations to it, you use the ContainerBuilder again like this:

var cb = new ContainerBuilder();
cb.Register(...);
...

cb.Update(existingContainer);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号