/// <summary> /// Reduce an <see cref="OrCriteria" /> that might contain a <see cref="ConstantCriteria" />. /// </summary> /// <param name="orCriteria"><see cref="OrCriteria" /> to be reduced.</param> /// <returns>Reduced criteria.</returns> /// <remarks> /// Falses will be removed, trues will replace the entire Or with a true. /// </remarks> static ICriteria Reduce(OrCriteria orCriteria) { if (orCriteria.Criteria.Any(c => c == ConstantCriteria.True)) { return(ConstantCriteria.True); } return(OrCriteria .Combine(orCriteria .Criteria .Select(Reduce) .Where(c => c != ConstantCriteria.False && c != null) .ToArray())); }
/// <summary> /// Rewrite an <see cref="OrCriteria" /> as a <see cref="BoolCriteria" />. /// </summary> /// <param name="or"><see cref="OrCriteria" /> to rewrite.</param> /// <returns><see cref="BoolCriteria" /> with the criteria from the Or mapped into Should.</returns> static BoolCriteria Rewrite(OrCriteria or) { return(new BoolCriteria(null, or.Criteria.Select(Compensate), null)); }