6
是否有可能测试另一个属性的代码中是否存在属性?从其他属性的代码中测试属性
假设你有下面的类定义:
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标签?
Ooooh!好的!我猜不是,但这只是一个猜测。 – zmbq