mercredi 16 mars 2016

Compare PropertyInfo name to an existing property in a safe way

I have a PropertyInfo, and I'd would like to check if it is a specific one. Knowing that its ReflectedType is correct, I could do this:

bool TestProperty(PropertyInfo prop)
{
    return prop.Name == "myPropertyName";
}

The problem is that my property myPropertyName could change name in the futur, and I would have no way to realize that the above code just broke.

Is there a safe way to test what I want, probably using Expression ?





Aucun commentaire:

Enregistrer un commentaire