Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all types registered with a Castle Windsor container instance

Tags:

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

Thanks

like image 553
UpTheCreek Avatar asked Oct 11 '09 08:10

UpTheCreek


People also ask

What is Windsor container?

Castle Windsor is a best of breed, mature Inversion of Control container available for . NET and Silverlight. The current version is 5.0, released in February 2019. Refer to the links on the right to download it from GitHub or NuGet.

What is Castle Windsor dependency injection?

Castle Windsor is Dependency Injection container. It means with the help of this you can inject your dependencies and use them without creating them with the help of new keyword.


1 Answers

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);
}
like image 156
Mauricio Scheffer Avatar answered Sep 27 '22 20:09

Mauricio Scheffer