Я использую этот код ...
container.Register(
AllTypes
.FromAssembly(Assembly.Load("MyNamespace.Dashboard"))
.BasedOn<IController>()
.Configure(component => component.LifeStyle.Transient
.Named(ControllerNameFromType(component.Implementation)))
);
... чтобы зарегистрировать мои контроллеры в контейнере, но я хотел бы иметь возможность зарегистрировать все контроллеры из всех сборок, чтобы сделать вещи более подключаемыми. Я думал, что код ниже должен работать, но это не так?
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)))
);
}