How to I make castle windsor automatically register controllers that don't have any dependencies?
I know I can specify it in the configuration XML, 开发者_高级运维but I'd like to not have to do so for every controller. For example: I have a controller without any dependencies being injected, but I'd rather not type out the XML component section in the config file or register it programmatically. Any ideas, suggestions, examples? Thanks for all the help!
This will automatically register all the controllers from the assembly of DependencyInjectionContainer class. No matter controllers have dependencies or not.
Register(
AllTypes.Of<IController>()
.FromAssembly(typeof(DependencyInjectionContainer).Assembly)
.Configure(c => c.LifeStyle.Transient)
);
精彩评论