public ValidationError(IRule rule, CachedExpression cachedExpression, object[] validationArguments, object value) { if (validationArguments == null) { throw new ArgumentNullException("validationArguments"); } if (value == null) { throw new ArgumentNullException("value"); } if (cachedExpression == null) { throw new ArgumentNullException("cachedExpression"); } if (rule == null) { throw new ArgumentNullException("rule"); } this.rule = rule; this.cachedExpression = cachedExpression; this.validationArguments = validationArguments; this.value = value; }
public bool HasError(CachedExpression cachedExpression, object value, out ValidationError[] validationErrors) { List<ValidationError> result; if (_hasExpressionError.TryGetValue(new CachedExpressionObjectPair(cachedExpression, value), out result)) { validationErrors = result.ToArray(); return true; } validationErrors = null; return false; }
public bool HasError(CachedExpression cachedExpression, object value, out ValidationError[] validationErrors) { List <ValidationError> result; if (hasExpressionError.TryGetValue(new CachedExpressionObjectPair(cachedExpression, value), out result)) { validationErrors = result.ToArray(); return(true); } validationErrors = null; return(false); }
/// <summary>Initializes a new instance of the <see cref="CachedExpressionObjectPair"/> class.</summary> /// <param name="cachedExpression">The cached expression.</param> /// <param name="value">The value.</param> public CachedExpressionObjectPair(CachedExpression cachedExpression, object value) { if (value == null) { throw new ArgumentNullException("value"); } if (cachedExpression == null) { throw new ArgumentNullException("cachedExpression"); } this.privateCachedExpression = cachedExpression; this.privateValue = value; hashCode = Utilities.CombineHash(cachedExpression.GetHashCode(), value.GetHashCode()); }
public CachedExpression Get(Expression expression) { if (expression == null) { throw new System.ArgumentNullException("expression"); } CachedExpression result; var key = new ExpressionKey(_comparer, expression); if (_cache.TryGetValue(key, out result)) { return(result); } else { result = new CachedExpression(expression); _cache.Add(key, result); return(result); } }
public EnumerableCompositionInvoker(RulesEngine rulesRulesEngine, Expression <Func <T, R> > enumerableCompositionExpression) { this.rulesRulesEngine = rulesRulesEngine; _compiledExpression = enumerableCompositionExpression.Compile(); _enumerableCompositionExpression = rulesRulesEngine.ExpressionCache.Get(enumerableCompositionExpression); }
public bool HasError(CachedExpression cachedExpression, object value) { return(hasExpressionError.ContainsKey(new CachedExpressionObjectPair(cachedExpression, value))); }
public RuleInvoker(IRule <R> rule, Expression <Func <T, R> > expressionToInvoke, CachedExpression expressionToBlame) { _rule = rule; _compiledExpression = expressionToInvoke.Compile(); _expressionToBlame = expressionToBlame; }
public CompositionInvoker(RulesEngine rulesRulesEngine, Expression <Func <T, R> > compositionExpression) { this.rulesRulesEngine = rulesRulesEngine; this.compiledExpression = compositionExpression.Compile(); this.cachedExpression = rulesRulesEngine.ExpressionCache.Get(compositionExpression); }
public bool HasError(CachedExpression cachedExpression, object value) { return _hasExpressionError.ContainsKey(new CachedExpressionObjectPair(cachedExpression, value)); }