3
votes

In Castle Windsor IoC, if you want to find the types that register a service, you can do it the following way:

List<Type> typeList = new List<Type>();

foreach (var item in moduleContainer.ResolveAll<IMyService>())
{
     var theType = typeof(item);
     Console.WriteLine("Found implementation: " + item.Name);
     typeList.insert(theType);
}

However, this method actually creates an instance of the type.

How do I resolve implementation Type(s) of a service interface without creating an instance?

1
I suppose you could moduleContainer.Release(item) immediately after adding it to the list. Is there a better way?Christian Stewart

1 Answers

2
votes
var handlers = container.Kernel.GetHandlers(typeof(IMyService));