扩展类时是否可以“更改”属性的值?类似于以下内容:
public class Mammal
{
[Validation(Required=true, HelpMessage="This is the body shape of a mammal")]
public virtual string BodyShape { get; set; }
}
public class Dog : Mammal
{
[Validation(HelpMessage = "This is the body shape of a dog")]
public override string BodyShape
{
get
{
return base.BodyShape;
}
set
{
base.BodyShape = value;
}
}
}
我希望能够读取 Dog.BodyShape 的属性,并将其设置为 Required=True,并且 HelpMessage =“这是狗的体型”。这可能吗?如果没有,任何可以直接在编译器中将“元数据”信息添加到属性的建议替代方案?