I have a class with some properties with the DisplayNameEx attribute that is derived from DisplayNameAttibute:
public class Settings
{
[DisplayNameEx("User")]
public UserData User { get; set; }
}
public class DisplayNameExAttribute : DisplayNameAttribute
{
public DisplayNameExAttribute(string id)
{
}
}
I pass the string name ID ALLWAYS as a name, so it would be easier to write code this way:
public class Settings
{
[DisplayNameEx()]
public UserData User { get; set; }
}
The name of the property. I can get the CallerMemberName attribute here:
public class DisplayNameExAttribute : DisplayNameAttribute
{
public DisplayNameExAttribute([CallerMemberName] string propertyName = null)
{
}
}
Can I also get the class name?
source
share