M
michelqa
I'm working on a custom xml serializer to store property information
of System.Windows.Forms.control object. For my testing I use a
ListView items object and try to get all object and properties-
collection contained in listView1.Items. My problem is the following:
I dont know how to tell if an object contain a "child" object. By
Example listView1.Font contains child object/properties like
"listView1.Font.Name" , "listView1.Font.Size" , ...
I already figure out how to manage the indexes when
p.GetIndexParameters().Length > 0
I stripped my code to show want I need to do.
//Note object is listView1.Items
using System.Reflection;
private static string SerializeObjectRecursive(object obj)
{
string XmlString="";
// ....
PropertyInfo[] PI=obj.GetType().GetProperties();
foreach (PropertyInfo pi in PI)
{
object MyObject=pi.GetValue(obj,null)
MessageBox.Show("I want to know if MyObject
contain other child object");
// If(MyObject== contain other child objects)
// XmlString += SerializeObjectRecursive
(MyObject);
// else
// XmlString +="<"+pi.Name+">"+
MyObject.ToString()+"</"+pi.Name+">";
}
// ....
return XmlString;
}
Thanks
of System.Windows.Forms.control object. For my testing I use a
ListView items object and try to get all object and properties-
collection contained in listView1.Items. My problem is the following:
I dont know how to tell if an object contain a "child" object. By
Example listView1.Font contains child object/properties like
"listView1.Font.Name" , "listView1.Font.Size" , ...
I already figure out how to manage the indexes when
p.GetIndexParameters().Length > 0
I stripped my code to show want I need to do.
//Note object is listView1.Items
using System.Reflection;
private static string SerializeObjectRecursive(object obj)
{
string XmlString="";
// ....
PropertyInfo[] PI=obj.GetType().GetProperties();
foreach (PropertyInfo pi in PI)
{
object MyObject=pi.GetValue(obj,null)
MessageBox.Show("I want to know if MyObject
contain other child object");
// If(MyObject== contain other child objects)
// XmlString += SerializeObjectRecursive
(MyObject);
// else
// XmlString +="<"+pi.Name+">"+
MyObject.ToString()+"</"+pi.Name+">";
}
// ....
return XmlString;
}
Thanks