是否可以在另一个属性的代码中测试一个属性的存在?
假设您有以下类定义:
public class Inception {
[Required]
[MyTest]
public int Levels { get; set; }
}
public class MyTestAttribute : ValidationAttribute {
public override bool IsValid(object o){
// return whether the property on which this attribute
// is applied also has the RequiredAttribute
}
}
... MyTestAttribute.IsValid 是否可以确定 Inception.Levels 是否具有RequiredAttribute?