I'm working on an application that consists of many modules, with some having dependencies on other modules. I now decided to use Autofac to solve circular dependencies and improve the architecture in general.
To configure autofac I use the xml method (http://code.google.com/p/autofac/wiki/XmlConfiguration).
Now I am not sure on how to implement Autofac. Do I need to have a reference to autofac in each module in my application? Meaning that i have to register all components each time I want to solve a dependency...
ContainerBuilder builder = new ContainerBuilder();
builder.RegisterModule(new ConfigurationSettingsReader("autofac", configPath));
IContainer container = builder.Build();
IWhatever w = container.Resolve<IWhatever>();
Is this the way to do it?
Or is it better to Wrap Autofac in a separate Module ? With this approach I would have to register the modules only once (when the application starts) and could just use the wrapped Autofac to resolve dependencies...
IWhatever w = container.Resolve<IWhatever>();
I hope someone can tell me the best way to use Autofac.
thanks!