Register all autofac modules from assembly by one line

.net, autofac, ioc-container

Solution

You can use the different overloads (see API doc) of the `RegisterAssemblyModules` method:

builder.RegisterAssemblyModules(Assembly.GetExecutingAssembly());

Problem

I can register all `Autofac` modules (classes derived from Autofac.Module) one by one using line like this `builder.RegisterModule(new LoggingInjectionModule());` But if I have 10 or more modules I want just to specify assembly, where `Autofac` can find all modules, that it need to register. Is there is any way to register all modules from specific assembly, namespace by single line or two lines?

Original source