protected void AddRule(string propertyName, ValidationRule rule) { if (String.IsNullOrWhiteSpace(propertyName) || rule == null) { return; } if (!RuleDict.ContainsKey(propertyName)) { RuleDict[propertyName] = new FltConfigValidationRuleCollection(); } RuleDict[propertyName].Add(rule); }
public FltConfigValidationRuleCollection Rules <TProperty>(Expression <Func <TEntity, TProperty> > expression) { if (expression == null) { throw new ArgumentException("Expression or Rule is null"); } var memberExpression = expression.Body as MemberExpression; if (memberExpression == null) { throw new ArgumentException("Expression is not MemberExpression"); } var propertyName = memberExpression.Member.Name; if (!RuleDict.ContainsKey(propertyName)) { RuleDict[propertyName] = new FltConfigValidationRuleCollection(); } return(RuleDict[propertyName]); }