I am working on an application that consists of many modules, some of which have dependencies on other modules. Now I decided to use Autofac to solve circular dependencies and improve the architecture as a whole.
To configure autofac, I use the xml method ( http://code.google.com/p/autofac/wiki/XmlConfiguration ).
Now I'm not sure how to implement Autofac. Do I need to have a link to autofac in every module in my application? This means that I have to register all components every time I want to solve the dependency ...
ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(new ConfigurationSettingsReader("autofac", configPath)); IContainer container = builder.Build(); IWhatever w = container.Resolve<IWhatever>();
Is this a way to do this?
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 can just use wrapped Autofac to resolve dependencies ...
IWhatever w = container.Resolve<IWhatever>();
I hope someone tells me the best way to use Autofac.
thanks!
source share