Sounds like a set of nested property invocations:
class X has a property called ShippingInfo; the type represented by ShippingInfo has a property Address; the type represented by Address has a property called Street.
So, assuming that you know the appropriate instance of class X to operate upon:
- tokenize the string via string.Split( ".".ToCharArray() ) to a string[], or something like that
- start with the known instance of X
- use reflection to obtain the MethodInfo for the ShippingInfo getter
- use reflection to obtain the Type returned by ShippingInfo get()
- Invoke the getter using reflection
- using the return value from the ShippingInfo get() and the Type of the return:
- obtain the MethodInfo for the Address getter in the returned type.....
and so on. You get the picture.
Seems a bit long and tedious, and it is. But that is how you would do it via reflection.
I wonder if it is possible to do the same thing with LINQ to Objects?
The answer to part 2 involves getting the initial value of X from your List<>.