Suppose you have a list of 100 complex nested object, and you want to spool all the values of a propery (identified by a pattern) of some subobject.
IE:
lista_tipiclassifornitura[i].OpzioneTariffaria.Codice
The immediate windows doesn't support loop, so I want to create a public static method like this:
string Spool(object c, string propertyPath)
I'll call this method as follow:
Spool(lista_tipiclassifornitura, "lista_tipiclassifornitura[#].OpzioneTariffaria.Codice")
The procedure replace the # with a 0, 1, 2, ecc and should access the Property "OpzioneTariffaria" and the property of this "Codice" through MemberInfo.
This example could help me? Getting Nested Object Property Value Using Reflection
Any suggestion?
Yes! It can be done.
This is how: