mercredi 1 avril 2015

GetIndexParameters() empty on Dictionary property

I'm using reflection to get some info about a class I'm exporting to excel. It loops through the properties to get their values.


I want it to also be able to handle indexed types like Lists and Dictionarys. However, the GetIndexParameters() method on the property is returning none. Am I using this wrong?


Here you can see that prop.Property (which is a PropertyInfo) is showing the value as a Dictionary<int, decimal>, but the indexParams has 0 length.


Loop logic (slightly modified for SO, partially pseudocode)



foreach (var prop in ExportingPropertiesInOrder)
{
//detect if it needs to have indexing applied.
var indexParams = prop.Property.GetIndexParameters();
var isIndexed = indexParams.Any();
if (!isIndexed)
{
//get value for property for export
}else{
//loop through indeces, get each value
}





Aucun commentaire:

Enregistrer un commentaire