Craig Richards
Craig Richards

Reputation: 59

Autofac integration into Prism 4

I am swapping out the standard Unity container in Prism 4 and run into a problem 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

Upvotes: 1

Views: 1268

Answers (1)

Peter Lillevold
Peter Lillevold

Reputation: 33920

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);

Upvotes: 4

Related Questions