How can I check if parent is declared back in child object.
class Team
{
Driver driver{ get; set;}
}
class Driver
{
Team parentTeam{ get; set;}
}
I have used the following way to get the properties:-
PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (PropertyInfo property in properties)
{
////if (!isParent) //need to find this.
//{
object propertyValue = property.GetValue(obj);
if (propertyValue != null)
{
// Get the deep clone of the field in the original object and assign the clone to the field in the new object.
property.SetValue(copiedObject, CloneProcedure(propertyValue));
}
//}
}
I want to skip through the parent when iterating through child. Note: Some of you may feel my classes are declared incorrectly but this is a legacy system and there is no chance of me restructuring the classes.
I have tried DeclaringType and I get property.DeclaringType but obj.GetType().DeclaringType is null.
Aucun commentaire:
Enregistrer un commentaire