views:

113

answers:

1

I've defined a for a specific interface within my StructureMap.config. There can be many different available concrete types defined.

I would like to programmatically retrieve a list of available instance keys (names) that are currently available without actually parsing the StructureMap.config file itself. Is there any way to do this?

A: 

Yes, you can inspect the container using its Model property.

For example, the following code will print the names of all instances of IWidget:

foreach(var instance in container.Model.InstancesOf<IWidget>())
{
    Console.WriteLine(instance.Name);
}
Joshua Flanagan