I have a class which loads it own values at startup from a database. I've
abridged the following a little, but given the following:
public class AppSettings
{
int notNestedType;
public class _nestedClass
{
int nestedType;
}
_nestedClass nested = new _nestedClass();
protected void Load()
{
MemberInfo[] MemberList = me.GetMembers(BindingFlags.NonPublic |
BindingFlags.Public | BindingFlags.Instance);
foreach (MemberInfo mi in MemberList)
{
if (mi.MemberType == MemberTypes.Field)
{
fld.SetValue(this, someValue);
}
else if (me.MemberType == MemberTypes.NestedType)
{
// enumerate the nested types so that we find _nestedType
// assuming fld = (MemberTypeInfo)_nestedType
// How do we do fld.SetValue(whatInstance, someValue);
}
}
}
}
Setting values on this.notNestedType is not a problem.
The problem is setting values on this.instance.nestedType as I have an
instance of this but don't know how to find the instance of nestedType.
I'd be very grateful for any pointers as I've spent hours searching google
and trying to come up with a solution.
Thanks,
Mark.