jeudi 12 mai 2016

Get nested properties name,value pair in C#

I have following classes.

public class AlloyDock
{
    public int LeftA { get; set; }
    public int RightA { get; set; }
}

public class Charger
{
    public int LeftC { get; set; }
    public int RightC { get; set; }
}
public class VehicleControlTest
{
    public Charger Charger1 { get; set; }
}
public class BasicControlTest
{
    public AlloyDock AlloyDock1 { get; set; }
}
class Appointment
{
    public BasicControlTest BasicControlTest1 { get; set; }
    public VehicleControlTest VehicleControlTest1 { get; set; }
}

I want to get name, value pair of leaf children in form of dictionary from list of objects of appointments.

Resultant data should be in Dictionary <"PropertyName", "Value"> form:

<"LeftA", 123>, <"RightA", 123>,<"RightA", 12113>, <"LeftA", 1323>

I am following link but its not returning desired results.

Help needed.





Aucun commentaire:

Enregistrer un commentaire