Purpose: What I'd like to do is to implement a console for my WinForm application to query certain objects' (i.e which implement an interface) properties at runtime. I'd like to list all instances of some Type, and display all properties of a selected instance. Yeah.
After reading the question "How do I get all instances of all loaded types that implement a given interface?", I'm ascertained that this cannot be done in a reasonable way (i.e without walking the heap?!) and evaluating a container approach, such that instances will register themselves to the container and unregister from it on destruction, etc, but I'm not satisfied with the alternatives I've got:
- Deriving all the classes from a base class that handles container-work: I wouldn't prefer inheritance.
- Implementing a container service and constructor-injecting it: The best one I've come up with, but I'm seeking a more transparent solution.
Question: When using a container approach, is there a better (more transparent, minimum lock-in) pattern?
Note: Alternative ways for the same purpose are also welcome.