In the next code, I need to count the number of items on the generic list, which is the property in another generic class. I don't know which value should I supply to GetValue() method. Any ideas?
// This is just an example class - there can be another class with a different name for DetailsList
public class Foo
{
public int Id { get; set; }
public string Name { get; set; }
public List<Bar> DetailsList { get; set; }
}
int NumberOfItems(TItem argsItem)
{
var detailsList = (IList) argsItem.GetType().GetProperty("DetailsList").GetValue(?); // how do I get a value of list?
return detailsList.Count;
}
s