vendredi 29 septembre 2017

Unable to recognize Dictionary object through Reflection

I am playing with Reflections and stopped with the next problem.

I can't recognize that the object is of the Dictionary<,> Type.

I receive PropertyInfo from Top object, and this property is of Dictionary<,> class for sure.

Then I do the next:

 if (pi.PropertyType.IsGenericType && pi.PropertyType == typeof(IDictionary<,>))

or

 if (pi.PropertyType.IsGenericType && pi.PropertyType == typeof(KeyValuePair<,>))

and in both cases the second comparision's without success.

Does anyone know another way to 100% recognize a Dictionary Type object?





Aucun commentaire:

Enregistrer un commentaire