N
nobody knows
Hi, after searching the Web and trying and searching I dont figure it out.
I have an object of myClass which contains several List<T> objects which I want to reflect:
public myClass {
public List<foo> foos;
public List<bar> bars;
public other members;
}
Here is one of my tries to reflect the mainobject with using the MyReflection method:
private static void MyReflection(object obj)
{
var type = obj.GetType();
PropertyInfo[] list = type.GetProperties();
foreach (var item in list)
{
System.Diagnostics.Debug.WriteLine(item.Name);
var smi = type.GetProperty(item.Name);
var value = smi.GetValue(obj, null);
if (value.GetType().Name == "List`1")
MyReflection(value);
}
}
The point is, "value" turns into a List<T> object type which I dont know how to iterate through.
Somebody else knows it?
Thanks.
I have an object of myClass which contains several List<T> objects which I want to reflect:
public myClass {
public List<foo> foos;
public List<bar> bars;
public other members;
}
Here is one of my tries to reflect the mainobject with using the MyReflection method:
private static void MyReflection(object obj)
{
var type = obj.GetType();
PropertyInfo[] list = type.GetProperties();
foreach (var item in list)
{
System.Diagnostics.Debug.WriteLine(item.Name);
var smi = type.GetProperty(item.Name);
var value = smi.GetValue(obj, null);
if (value.GetType().Name == "List`1")
MyReflection(value);
}
}
The point is, "value" turns into a List<T> object type which I dont know how to iterate through.
Somebody else knows it?
Thanks.