Ejemplo n.º 1
0
 /// <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>
 private 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));
 }
Ejemplo n.º 2
0
        /// <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)));
        }
 JObject Build(NotCriteria criteria)
 {
     return new JObject(new JProperty(criteria.Name, Build(criteria.Criteria)));
 }
Ejemplo n.º 4
0
 /// <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));
 }