示例#1
0
 /// <summary>
 /// Specification execution with input
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="specificaiton"></param>
 /// <returns></returns>
 public RuleEngine <TResult> ValidateIf(Func <bool> condition, BaseSpecification specificaiton)
 {
     if (!condition())
     {
         return(this);
     }
     return(Validate(specificaiton));
 }
示例#2
0
 /// <summary>
 /// Specification execution with input
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="condition"></param>
 /// <param name="specificaiton"></param>
 /// <param name="input"></param>
 /// <returns></returns>
 public RuleEngine <TResult> ValidateIf <T>(Func <bool> condition, BaseSpecification <T> specificaiton, T input)
 {
     if (!condition())
     {
         return(this);
     }
     return(Validate(specificaiton, input));
 }
示例#3
0
        /// <summary>
        /// Specification execution with input
        /// </summary>
        /// <param name="specificaiton"></param>
        /// <returns></returns>
        public RuleEngine <TResult> Validate(BaseSpecification specificaiton)
        {
            var result = _strategy.Execute(specificaiton);

            if (!result.IsNull() && !result.IsValid)
            {
                var specResult = new SpecificationErrorInfo(result);
                _specificationErrors.Add(specResult);
            }

            return(this);
        }
 /// <summary>
 /// Adds specification to the container to be executed
 /// </summary>
 /// <param name="specification"></param>
 public void Add(BaseSpecification <T> specification)
 {
     _specificaitons.Add(specification);
 }