コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        /// <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());
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 public EnumerableCompositionInvoker(RulesEngine rulesRulesEngine, Expression <Func <T, R> > enumerableCompositionExpression)
 {
     this.rulesRulesEngine            = rulesRulesEngine;
     _compiledExpression              = enumerableCompositionExpression.Compile();
     _enumerableCompositionExpression = rulesRulesEngine.ExpressionCache.Get(enumerableCompositionExpression);
 }
コード例 #7
0
 public bool HasError(CachedExpression cachedExpression, object value)
 {
     return(hasExpressionError.ContainsKey(new CachedExpressionObjectPair(cachedExpression, value)));
 }
コード例 #8
0
ファイル: RuleInvoker.cs プロジェクト: rmatthews888/WheelMUD
 public RuleInvoker(IRule <R> rule, Expression <Func <T, R> > expressionToInvoke, CachedExpression expressionToBlame)
 {
     _rule = rule;
     _compiledExpression = expressionToInvoke.Compile();
     _expressionToBlame  = expressionToBlame;
 }
コード例 #9
0
 public CompositionInvoker(RulesEngine rulesRulesEngine, Expression <Func <T, R> > compositionExpression)
 {
     this.rulesRulesEngine   = rulesRulesEngine;
     this.compiledExpression = compositionExpression.Compile();
     this.cachedExpression   = rulesRulesEngine.ExpressionCache.Get(compositionExpression);
 }
コード例 #10
0
 public bool HasError(CachedExpression cachedExpression, object value)
 {
     return _hasExpressionError.ContainsKey(new CachedExpressionObjectPair(cachedExpression, value));
 }