What's the easiest way of programatically listing registered types in Castle Windsor?
Thanks
Use IKernel.GetAssignableHandlers(typeof(object))
:
IWindsorContainer container = ...
foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object))) {
Console.WriteLine("{0} {1}",
handler.ComponentModel.Service,
handler.ComponentModel.Implementation);
}
Further to Mauricio's excellent answer, if handler.ComponentModel.Service
cannot be found use this instead:
IWindsorContainer container = ...
foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object))) {
Console.WriteLine("{0} {1}",
String.Join(",", handler.ComponentModel.Services),
handler.ComponentModel.Implementation);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.