List all types registered with a Castle Windsor container instance

怎甘沉沦 提交于 2019-11-27 05:49:49

问题


What's the easiest way of programatically listing registered types in Castle Windsor?

Thanks


回答1:


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);
}


来源:https://stackoverflow.com/questions/1550190/list-all-types-registered-with-a-castle-windsor-container-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!