/// <summary> /// Rewrite a <see cref="NotCriteria" /> as a <see cref="BoolCriteria" />. /// </summary> /// <param name="not">NotCriteria to rewrite.</param> /// <returns><see cref="BoolCriteria" /> with the criteria from Not mapped into MustNot.</returns> static BoolCriteria Rewrite(NotCriteria not) { var mustNotCriteria = (not.Criteria is OrCriteria) ? ((OrCriteria)not.Criteria).Criteria : Enumerable.Repeat(not.Criteria, 1); return(new BoolCriteria(null, null, mustNotCriteria.Select(Compensate))); }
/// <summary> /// Rewrite a <see cref="ConstantCriteria" /> as a <see cref="MatchAllCriteria" /> that might be /// wrapped in a <see cref="NotCriteria" /> depending on whether it is true or false respectively. /// </summary> /// <param name="constant"><see cref="ConstantCriteria" /> to rewrite.</param> /// <returns> /// <see cref="MatchAllCriteria" /> if true; otherwise a <see cref="MatchAllCriteria" /> /// wrapped in a <see cref="NotCriteria" /> if false. /// </returns> static ICriteria Rewrite(ConstantCriteria constant) { return(constant == ConstantCriteria.True ? MatchAllCriteria.Instance : NotCriteria.Create(MatchAllCriteria.Instance)); }