lundi 21 mars 2022

Using reflection to assess class properties from passed property

How to escape the property and assess the properties of root class?

public class A
{
    public string Interval { get; set; } // <= assess property
    public string Symbol { get; set; } // <= assess property

    [JsonConverter(typeof(AJsonConverter))]
    public List<string> Params { get; set; }
}

public class AJsonConverter : JsonConverter<List<string>>
{
    public override void Write(Utf8JsonWriter writer, List<string> value, JsonSerializerOptions options)
    {
        // assess Interval and Symbol through value
        value.GetType().GetProperties()
    }
}




Aucun commentaire:

Enregistrer un commentaire