/// <summary> /// Gets a new specification expression which corresponds to the logical /// combination of the specified objects: <c>AND</c>. /// </summary> /// <returns>A specification expression.</returns> /// <param name="spec">A specification expression.</param> /// <param name="composeWith">Another specification expression.</param> /// <typeparam name="T">The generic type of the specifications.</typeparam> public static ISpecificationExpression <T> And <T>(this ISpecificationExpression <T> spec, ISpecificationExpression <T> composeWith) { var func1 = spec.GetExpressionOrThrow(); var func2 = composeWith.GetExpressionOrThrow(); return(Spec.Expr(func1.And(func2))); }
/// <summary> /// Gets a new specification expression which corresponds to the logical /// negation of the specified object: <c>NOT</c>. /// </summary> /// <returns>A specification expression.</returns> /// <param name="spec">A specification expression.</param> /// <typeparam name="T">The generic type of the specification.</typeparam> public static ISpecificationExpression <T> Not <T>(this ISpecificationExpression <T> spec) { return(Spec.Expr(spec.GetExpressionOrThrow().Not())); }
/// <summary> /// Gets a function from a specification expression, as if it were a /// <see cref="ISpecificationFunction{T}"/>. /// </summary> /// <returns>A function, representing the compiled expression contained within the specification expression.</returns> /// <param name="spec">A specification expression.</param> /// <typeparam name="T">The generic type of the specification.</typeparam> public static Func <T, bool> GetFunction <T>(this ISpecificationExpression <T> spec) { var expr = spec.GetExpressionOrThrow(); return(expr.Compile()); }