I am using this code ...
container.Register( AllTypes .FromAssembly(Assembly.Load("MyNamespace.Dashboard")) .BasedOn<IController>() .Configure(component => component.LifeStyle.Transient .Named(ControllerNameFromType(component.Implementation))) );
... to register my controllers in a container, but I would like to be able to register all controllers from all assemblies to make things more connectable. I thought the code below should work, but it does not exist?
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { container.Register( AllTypes .FromAssembly(assembly) .BasedOn<IController>() .Configure(component => component.LifeStyle.Transient .Named(ControllerNameFromType(component.Implementation))) ); }
source share