E
Ericd
I am trying to perform a funciton that is best described as instantiating a
class and its complete list of subclasses by reflection. I would like to
pass this newly instantiated class (that does not have its subclasses
instantiated) into a routine that instantiates all subclasses.
Say this class as a class hierarchy as follows and each class has a
constructor with no paramters:
MyClass
SubClass1
SubClass2
SubSubClass1
SubClass3
I understand how to traverse the classes by utilizing GetType.GetNestedTypes
and also being able to create a new object of one of these subclasses using
Activator.CreateInance but the part that I am not comprehending is how I can
use this information to instantiate the classes in my original passed in
class so by the end of the routine all of its contained subclasses have been
instantiated.
Ultimately I really would like to be able to pass in a string of the "root"
class (be it the main or subclass) and instantiate all of its subclasses.
Then by passing in a name of a property in one of these classes to be able
to set it by name with a passed in value. These are secondary desires but
the inital full instantiate of all classes is my current block.
Thanks for any help you can provide.
class and its complete list of subclasses by reflection. I would like to
pass this newly instantiated class (that does not have its subclasses
instantiated) into a routine that instantiates all subclasses.
Say this class as a class hierarchy as follows and each class has a
constructor with no paramters:
MyClass
SubClass1
SubClass2
SubSubClass1
SubClass3
I understand how to traverse the classes by utilizing GetType.GetNestedTypes
and also being able to create a new object of one of these subclasses using
Activator.CreateInance but the part that I am not comprehending is how I can
use this information to instantiate the classes in my original passed in
class so by the end of the routine all of its contained subclasses have been
instantiated.
Ultimately I really would like to be able to pass in a string of the "root"
class (be it the main or subclass) and instantiate all of its subclasses.
Then by passing in a name of a property in one of these classes to be able
to set it by name with a passed in value. These are secondary desires but
the inital full instantiate of all classes is my current block.
Thanks for any help you can provide.