C
chris fellows
In VS2005 (C#) I want to set the properties of an object dynamically at
runtime from an XML configuration file but without having to know the
property name when writing the code. The properties are user-defined classes
so I need to be able to iterate through the properties of each sub-object
and set the property accordingly.
For example, Instead of having to write the code
MyObject.SubObjectOne.MyStringProperty = "Some text" I will configure it
like this <Property Name="MyObject.SubObjectOne.MyStringProperty"
Value="Some text"/>.
Can someone help me out as to how to do this? I can iterate thru' the
properties of MyObject (using PropertyInfo) but can't see how to iterate
thru' the properties of each sub-object or even how to set the property
value.
runtime from an XML configuration file but without having to know the
property name when writing the code. The properties are user-defined classes
so I need to be able to iterate through the properties of each sub-object
and set the property accordingly.
For example, Instead of having to write the code
MyObject.SubObjectOne.MyStringProperty = "Some text" I will configure it
like this <Property Name="MyObject.SubObjectOne.MyStringProperty"
Value="Some text"/>.
Can someone help me out as to how to do this? I can iterate thru' the
properties of MyObject (using PropertyInfo) but can't see how to iterate
thru' the properties of each sub-object or even how to set the property
value.