vendredi 18 août 2017

handle this datatype whith reflection

I don't know how to handle this datatype.

object wert = x.GetValue(instanz);

List<object> element = new List<object>();

if (wert.GetType().GetInterfaces().Any(t => t == typeof(IEnumerable)))
{                           
    foreach (var item in wert as IEnumerable)
    {    
     //this works for Lists, but not for the Datatype i have here(see link in my post)  
     //I get "null" for "y.GetValue(item)"       
     element.Add(item.GetType().GetProperties().ToDictionary(y => y.Name, y => y.GetValue(item)));
    }
}

Immediate window:

wert as IEnumerable

Will return:

Count = 1
    [0]: "51000"

Here you can find deeper informations: click

For the y in the foreach will fail when it hits y.GetValue(item): click

How can I solve this problem ?





Aucun commentaire:

Enregistrer un commentaire