/// <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> /// Transforms the specification to a target type, using a selector expression. /// </summary> /// <returns>The transformed specification expression.</returns> /// <param name="selector">A selector to specify how an instance of the transformed/target type may be used to get an instance of the originally-specified type.</param> /// <typeparam name="TTarget">The target type.</typeparam> public ISpecificationExpression <TTarget> To <TTarget>(Expression <Func <TTarget, TOrigin> > selector) { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } var newExpression = expressionTransformer.Transform(spec.GetExpression(), selector); return(Spec.Expr(newExpression)); }
/// <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())); }