クラス内のすべてのプロパティを再帰的に調べる必要があります。プロパティが文字列である場合は、カスタムロジックを実行する必要があります。再帰の行に何を置く必要があるか教えてください。
void ProcessAllStrings<T>(ref T objToRip)
{
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Type typeParameterType = typeof (T);
foreach (PropertyInfo p in typeParameterType.GetProperties(flags))
{
Type currentNodeType = p.PropertyType;
if (currentNodeType == typeof (String))
{
//here I do my custom string handling. Code deleted
}
//if non primitive and non string then recurse. (nested/inner class instances)
// see http://stackoverflow.com/questions/4444908/detecting-native-objects-with-reflection
else if (currentNodeType != typeof (object) && Type.GetTypeCode(currentNodeType) == TypeCode.Object)
{
//I need to get the reference to this property which happens to be a nested class
//but propertyInfo only provides GetValue(). No GetReference available..
ProcessAllStrings(ref "dont know what to put here");
}
}
}