vendredi 19 novembre 2021

How do I Dynamically set properties from the name in a parent class?

How do I dynamically set the "Name" properties of each of the AlarmModel's as the name of the model (i.e. HardwareFault) from the parent class?

public class NotificationModel
{
    public string UnrelatedProperty { get; set; }  // any solution should ignore other properties.

    public AlarmModel HardwareFault{ get; set; }

    public AlarmModel TimeoutFault { get; set; }

    public AlarmModel GenericFault { get; set; }
}

public class AlarmModel
{
    public string Name { get; set; }

    public bool isActive { get; set; }

    public bool isEnabled { get; set; }

    public bool isSilenced { get; set; }
}




Aucun commentaire:

Enregistrer un commentaire