示例#1
0
        static public Predicate CreateLogicalOrPredicate(Predicate lhsPred, Predicate rhsPred)
        {
            if (lhsPred.Equals(TRUE_PREDICATE) || rhsPred.Equals(TRUE_PREDICATE))
            {
                return(TRUE_PREDICATE);
            }
            if (lhsPred.Equals(FALSE_PREDICATE))
            {
                return(rhsPred);
            }
            if (rhsPred.Equals(FALSE_PREDICATE))
            {
                return(lhsPred);
            }

            LogicalAndPredicate inc = null;

            if (lhsPred is LogicalAndPredicate)
            {
                inc = lhsPred as LogicalAndPredicate;
            }

            if (inc == null || !inc.Inverse)
            {
                inc = new LogicalAndPredicate();
                inc.Invert();
                inc.Children.Add(lhsPred);
            }
            inc.Children.Add(rhsPred);

            return(inc);
        }
示例#2
0
 public int CompareTo(object obj)
 {
     if (obj is LogicalAndPredicate)
     {
         LogicalAndPredicate other = (LogicalAndPredicate)obj;
         if (Inverse == other.Inverse)
         {
             if (members.Count == other.members.Count)
             {
                 for (int i = 0; i < members.Count; i++)
                 {
                     if (members[i] != other.members[i])
                     {
                         return(-1);
                     }
                 }
                 return(0); //members.CompareTo(other.members);
             }
         }
     }
     return(-1);
 }