dimanche 23 octobre 2016

Determining if a field is using a generic parameter

I've been baffled by this and can't seem to get my head around it so hopefully someone can point me in the right direction.

I have a class as follows:

public class Foo<T>
{
    public List<T> Data;
}

Now I'm writing code to reflect this class and want to work out a way of determining that the field Data has a generic parameter being used.

My initial approach was to continue going down as many levels as I could and once I hit the IsGenericParameter field set to true I would rather than reflect the type name instead place a "Generic Argument" string there, however I can't seem to get this to work the way I want it to.

I've looked around but every solution I've found seems to point to a dead end with this at the moment.





Aucun commentaire:

Enregistrer un commentaire