Probem: A parent abstract class must be aware of all his existing child classes. The parent class must also be able to list all the class names of his child classes through a method.
Context: In my situation, the parent class is used to represent any input data type for a web form (such as email, text, boolean, integer, image, and so on). The child classes represent each specific data types. So there is a Boolean class, an Image class, an Integer class, etc.
The language I'm using is C#.
How would you do that?
edit: The reason why I need to know the child classes is because I need to know all the input data types available in order to list them. Also, I need to access the methods of each data type (child class) to get its properties.
So, for example, I need to get an instance of the Image class simply with the string "Image" that is stored in a database. If the base class knowns all its children, I will be able to ask it to get me the child represented by the string "Image", and it will return an instance of the Image class.
I thought of implementing it by making each child a Singleton, and adding itself to a list of children (at construction) that would be a private field of the base DataType class.