Hello,
I wondered if anyone could help. I wish to retrieve the PropertyInfo[]
of a specific interface but can't work out how to do this in a type
safe way.
Basically I don't want to do this:
void Reflect(IMyObject objectToReflect)
{
PropertyInfo[] myObjectProperties =
objectToReflect.GetType().GetProperties();
}
Reason being it may have multiple interfaces or it's own properties and
the reflection is based on the object not on the parameter type (i.e.
GetType() returns will return object type which inherits the interface
not the interface itself).
So what I'm trying to do is this instead:
void Reflect(IMyObject objectToReflect)
{
PropertyInfo[] myObjectProperties =
Type.GetType(IMyObject).GetProperties();
}
But I can't find the code to do it (unless I use a string - but then
that's not type safe).
Anyone have any ideas?
Most grateful.