我试图创建显示属性CountryText反射在显示自定义属性MVC
[DisplayNameProperty("CountryText")]
public string Country { get; set; }
public string CountryText { get; set; }
这个属性
namespace Registration.Front.Web.Validators
{
public class RegistrationDisplayNameAttribute:DisplayNameAttribute
{
private readonly PropertyInfo _proprtyInfo;
public RegistrationDisplayNameAttribute(string resourceKey):base(resourceKey)
{
}
public override string DisplayName
{
get
{
if(_proprtyInfo==null)
}
}
}
}
我该怎么办的代码值的自定义属性在我的属性代码中获得名为resourceKey
的fild的值的反射?
您需要将'Sender'对象也加入到您的构造函数中,不幸的是,这对于一个属性是不可能的,因为您需要使用常量值 – LukeHennerley