1
是否可以发送参数到自定义验证规则?发送参数到自定义验证规则
我的有效性规则:
public class CustomTypeSelectedRule : IValidationRule
{
public ValidationResult Validate(object input)
{
// Here I need an extra value from the class calling
// the validation rule.
return ValidationResult.Success;
}
}
我使用有效性规则属性:
[ContractValidation(typeof(ValidationRules.CustomTypeSelectedRule))]
public int CustomType
{
get
{
return this.customType;
}
set
{
this.customType = value;
}
}
任何输入被感激,谢谢!
需要通过代码来做到这一点。我找到了使用企业库验证框架的方法。 – thomasmartinsen 2011-04-19 11:19:48