I would like an abstract class, AbstractComponentAggregate, which has many AbstractComponents. Users of my framework will create their components by extending AbstractComponent and appending the component to this AbstractComponentAggregate.
I would like to know if there is an elegant way to have AbstractComponentAggregate to store a dictionary of the concrete classes that extend AbstractComponents. Note, that I want to store many concrete classes, each of which is an AbstractComponent. This is different than storing a list of AbstractComponents.
Thus, you can invoke a method on AbstractComponentAggregate, such as:
AbstractComponentAggregate.GetComponent(), which returns type T. T is the concrete class, and we ensure T is of type AbstractComponent.
Something similar to this is done in Unity3d, and I would like to emulate this.