2011-04-14 31 views
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; 
    } 
} 

任何输入被感激,谢谢!

回答