Which is the best practice for extracting property from object ,so that we can take its value?
We have the following code structure:
public List<Group> Activities { get; set; }
In Group we have:
public List<Span> Spans { get; set; }
In Span class we have:
public object Activity { get; set; }
In method I have the following loop that I want to take from object Activity property Id from TV:
foreach (var activity in result.Activities)
{
if (activity.Spans != null)
{
foreach (var span in activity.Spans)
{
if (span.Activity != null)
{
foreach (var propertyInfo in typeof(Spans).GetProperties())
{
if (propertyInfo.Name == "Activity")
{
//take value from activity
}
}
}
}
}
}
In span.Activity we have : { Time = 123, EndTime = 123, Points = [ -48, -49 ], PointsStart = [ 0, -2, ], TV = [ { "time": "123", "Id": 7, "TitleId": 5 } ] }
I need to take from TV the Id property value and add it later to a list. Which is the best practice to do it and how?
Aucun commentaire:
Enregistrer un commentaire