I have the following code:
public interface IFoo
{
[DisplayName("test")]
string Name { get; set; }
}
public class Foo : IFoo
{
public string Name { get; set; }
}
Using reflection I need to get the attribute from the property Name
. However I don't know if the Type
I will receive is an interface or the concrete class.
If I try to do a prop.GetCustomAttributes(true)
on the concrete class it doesn't return the attribute I've set on the interface. I would like it to return in this case.
Is there a method to get attributes defined on the concrete class and the interface as well? Or how could I handle this?