Example #1
0
        /// <summary>
        /// Joins specifications in an 'Or' condition.
        ///
        ///
        /// <exception cref="SpecificationException"></exception>
        ///
        /// </summary>
        /// <typeparam name="T">The type of entity that is the subject of the specification.</typeparam>
        /// <param name="current">Left operand specification instance.</param>
        /// <param name="right">The collection of specification to join in an 'Or' condition.</param>
        /// <returns>Resulting specification.</returns>
        public static SpecificationBase <T> Or <T>(this SpecificationBase <T> current, params SpecificationBase <T>[] right)
        {
            var specifications = new List <SpecificationBase <T> >(right.Length + 1)
            {
                current
            };

            specifications.AddRange(right);
            return(new OrSpecification <T>(specifications));
        }
Example #2
0
 /// <summary>
 /// Accumulates predicate over specifications sequence.
 /// </summary>
 /// <param name="predicate">Predicate for accumulation.</param>
 /// <param name="specification">Specification to accumulate with current <paramref name="predicate"/>predicate.</param>
 /// <returns>Resulting predicate.</returns>
 protected override Expression <Func <T, bool> > AccumulateExpression(Expression <Func <T, bool> > predicate, SpecificationBase <T> specification)
 {
     return(predicate.Or(specification));
 }
Example #3
0
 /// <summary>
 /// Initialise a new instance of the specification class that joins two specifications in an 'Or' condition.
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <param name="left">Left operand specification instance.</param>
 /// <param name="right">Right operand specification instance.</param>
 public OrSpecification(SpecificationBase <T> left, SpecificationBase <T> right)
     : base(left, right)
 {
 }
Example #4
0
 /// <summary>
 /// Creates 'Not' condition specification from <paramref name="current"/>
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <typeparam name="T">The type of entity that is the subject of the specification.</typeparam>
 /// <param name="current">Current specification</param>
 /// <returns>Resulting specification</returns>
 public static SpecificationBase <T> Not <T>(this SpecificationBase <T> current)
 {
     return(new NotSpecification <T>(current));
 }
Example #5
0
 /// <summary>
 /// Joins specifications in an 'Or' condition.
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <typeparam name="T">The type of entity that is the subject of the specification.</typeparam>
 /// <param name="left">Left operand specification instance.</param>
 /// <param name="right">Right operand specification instance.</param>
 /// <returns>Resulting specification.</returns>
 public static SpecificationBase <T> Or <T>(this SpecificationBase <T> left, SpecificationBase <T> right)
 {
     return(new OrSpecification <T>(left, right));
 }
Example #6
0
 /// <summary>
 /// Joins specifications in an 'And' condition.
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <typeparam name="T">The type of entity that is the subject of the specification.</typeparam>
 /// <param name="current">Left operand specification instance.</param>
 /// <param name="right">Right operand specification instance.</param>
 /// <returns>Resulting specification.</returns>
 public static SpecificationBase <T> And <T>(this SpecificationBase <T> current, SpecificationBase <T> right)
 {
     return(new AndSpecification <T>(current, right));
 }
Example #7
0
 /// <summary>
 /// Joins specifications in an 'OrNot' condition.
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <typeparam name="T">The type of entity that is the subject of the specification.</typeparam>
 /// <param name="current">Left operand specification instance.</param>
 /// <param name="right">Right operand specification instance.</param>
 /// <returns>Resulting specification.</returns>
 public static SpecificationBase <T> OrNot <T>(this SpecificationBase <T> current, SpecificationBase <T> right)
 {
     return(current.Or(right.Not()));
 }
Example #8
0
 /// <summary>
 /// Initialise a new instance of the specification class that represents a 'Not' condition.
 ///
 ///
 /// <exception cref="SpecificationException"></exception>
 ///
 /// </summary>
 /// <param name="specification">The specification to apply 'Not' condition.</param>
 /// <exception cref="SpecificationException">Thrown when current specification is null.</exception>
 public NotSpecification(SpecificationBase <T> specification)
 {
     Guard.AgainstNullReference <SpecificationException>(specification, "specification",
                                                         CompositeSpecification <T> .NULL_COMPOSITION_MESSAGE);
     this._specification = specification;
 }
Example #9
0
 /// <summary>
 /// Accumulates predicate over specifications sequence.
 /// </summary>
 /// <param name="predicate">Predicate for accumulation.</param>
 /// <param name="specification">Specification to accumulate with current <paramref name="predicate"/>predicate.</param>
 /// <returns>Resulting predicate.</returns>
 protected abstract Expression <Func <T, bool> > AccumulateExpression(Expression <Func <T, bool> > predicate, SpecificationBase <T> specification);