public void ConjoinsCriteria()
        {
            var spec1 = new IntegerPredicate(i => i == 0);
            var spec2 = new IntegerPredicate(i => i > 0);

            var criteria1 = spec1.Criteria;
            var criteria2 = spec2.Criteria;

            var conjoinedSpec = new Conjunction<int>(spec1, spec2);
            var conjoinedCriteria = conjoinedSpec.Criteria;

            Assert.That(conjoinedCriteria.Body, Is.AssignableTo<BinaryExpression>());

            var binary = (BinaryExpression)conjoinedCriteria.Body;

            Assert.That(binary.NodeType, Is.EqualTo(ExpressionType.AndAlso));
            Assert.That(binary.Conversion, Is.Null);
            Assert.That(binary.Left.ToString(), Is.EqualTo(criteria1.Body.ToString()));
            Assert.That(binary.Right.ToString(), Is.EqualTo(criteria2.Body.ToString()));
            Assert.That(binary.Method, Is.Null);
            Assert.That(binary.IsLifted, Is.False);
            Assert.That(binary.IsLiftedToNull, Is.False);

            ExpressionWriter.Write(conjoinedCriteria);
        }
Beispiel #2
0
        internal override WalkedToken Walk(WalkedToken left, WalkedToken right)
        {
            Conjunction crit = new Conjunction();

            crit.Add(left.Criterion);
            crit.Add(right.Criterion);
            return WalkedToken.FromCriterion(crit);
        }
        public void SelectsConjunction()
        {
            var spec1 = new IntegerGreaterThanZero();
            var spec2 = new IntegerPredicate(i => i > -1);
            var conjoinedSpec = new Conjunction<int>(spec1, spec2);

            Assert.That(conjoinedSpec.IsSatisfiedBy(1), Is.True);
            Assert.That(conjoinedSpec.IsSatisfiedBy(0), Is.False);
            Assert.That(conjoinedSpec.IsSatisfiedBy(-1), Is.False);
        }
 /// <summary>
 /// Gets a string representation of the given conjunction.
 /// </summary>
 /// <param name="conjunction">The conjunction to convert to a string.</param>
 /// <returns>The string representation.</returns>
 public string ToString(Conjunction conjunction)
 {
     switch (conjunction)
     {
         case Conjunction.And:
             return "AND";
         case Conjunction.Or:
             return "OR";
         default:
             throw new ArgumentException(Resources.UnknownConjunction, "conjunction");
     }
 }
Beispiel #5
0
        private static void BuildQueryFrom(Query query, ICriteria criteria)
        {
            IList <ICriterion> critrions = new List <ICriterion>();

            if (query.Criteria != null)
            {
                foreach (Criterion c in query.Criteria)
                {
                    ICriterion criterion;

                    switch (c.criteriaOperator)
                    {
                    case CriteriaOperator.Equal:
                        criterion = Expression.Eq(c.PropertyName, c.Value);
                        break;

                    case CriteriaOperator.LesserThanOrEqual:
                        criterion = Expression.Le(c.PropertyName, c.Value);
                        break;

                    default:
                        throw new ApplicationException("No operator defined");
                    }

                    critrions.Add(criterion);
                }

                if (query.QueryOperator == QueryOperator.And)
                {
                    Conjunction andSubQuery = Expression.Conjunction();
                    foreach (ICriterion criterion in critrions)
                    {
                        andSubQuery.Add(criterion);
                    }

                    criteria.Add(andSubQuery);
                }
                else
                {
                    Disjunction orSubQuery = Expression.Disjunction();
                    foreach (ICriterion criterion in critrions)
                    {
                        orSubQuery.Add(criterion);
                    }
                    criteria.Add(orSubQuery);
                }

                foreach (Query sub in query.SubQueries)
                {
                    BuildQueryFrom(sub, criteria);
                }
            }
        }
Beispiel #6
0
        public static IList <Airfield> FindSimilarAirfieldsByName(String value, String country)
        {
            ICriteria   cr = NHibernateHelper.GetCurrentSession().CreateCriteria(typeof(Airfield));
            Conjunction c  = new Conjunction();

            foreach (String s in value.Split(" ".ToCharArray()))
            {
                c.Add(Restrictions.Like("AirfieldName", s, MatchMode.Anywhere));
            }
            cr.Add(c);
            cr.Add(Restrictions.Eq("Country", country));
            return(cr.List <Airfield>());
        }
        public void TestSimpleExample()
        {
            Disjunction disj1 = new Disjunction(A, Bneg);
            Conjunction conj  = new Conjunction(disj1, C);

            BooleanExpression actual = conj.ToDNF();

            BooleanExpression expected = new Disjunction(new Conjunction(A, C), new Conjunction(Bneg, C));

            Assert.True(actual.Is_DNF());
            Assert.True(expected.Is_DNF());
            Assert.Equal(expected, actual);
        }
        private Conjunction FilterGarment(string[] searchlist, int number)
        {
            Conjunction c = new Conjunction();

            foreach (string s in searchlist)
            {
                c.Add(Expression.Or(Expression.InsensitiveLike(string.Format("garment{0}.Title", number), s, MatchMode.Anywhere), Expression.InsensitiveLike(string.Format("garment{0}.Keywords", number), s, MatchMode.Anywhere)));
            }

            c.Add(Expression.Not(Expression.Eq(string.Format("garment{0}.Id", number), 0)));

            return(c);
        }
Beispiel #9
0
        private void VisitNotExpression(UnaryExpression expr)
        {
            var criterions = GetCriterion(rootCriteria, session, expr.Operand);

            Conjunction conjunction = Restrictions.Conjunction();

            foreach (var criterion in criterions)
            {
                conjunction.Add(criterion);
            }

            CurrentCriterions.Add(Restrictions.Not(conjunction));
        }
        public void FlattenWithNegation()
        {
            Conjunction conj1 = new Conjunction(new Negation(A), new Negation(B));
            Conjunction conj2 = new Conjunction(new Negation(conj1), conj1);

            BooleanExpression actual = conj2.Flatten();

            Conjunction expected = new Conjunction(new Negation(new Conjunction(new Negation(A), new Negation(B))),
                                                   new Negation(A),
                                                   new Negation(B));

            Assert.Equal(expected, actual);
        }
        public void ShowMessageWhenSearchedClientsCouldNotBeLoaded()
        {
            // Arrange
            this._mockRepository.Setup(x => x.GetQuantityByCriteria <Client>(It.IsAny <ICriterion>())).Throws <Exception>();

            Conjunction clientConjunction = Restrictions.Conjunction();
            Tuple <ICriterion, Expression <Func <Client, CityToPostalCode> >, ICriterion> expectedTuple = new Tuple <ICriterion, Expression <Func <Client, CityToPostalCode> >, ICriterion>(clientConjunction, null, null);

            // Act
            Messenger.Default.Send(new NotificationMessage <Tuple <ICriterion, Expression <Func <Client, CityToPostalCode> >, ICriterion> >(expectedTuple, Resources.Message_ClientSearchCriteriaForClientSearchVM));

            // Assert
            this._mockDialogService.Verify(x => x.ShowExceptionMessage(It.IsAny <Exception>(), It.IsAny <string>()), Times.Once);
        }
Beispiel #12
0
        /// <summary>
        /// Gets a string representation of the given conjunction.
        /// </summary>
        /// <param name="conjunction">The conjunction to convert to a string.</param>
        /// <returns>The string representation.</returns>
        public string ToString(Conjunction conjunction)
        {
            switch (conjunction)
            {
            case Conjunction.And:
                return("AND");

            case Conjunction.Or:
                return("OR");

            default:
                throw new ArgumentException(Resources.UnknownConjunction, "conjunction");
            }
        }
Beispiel #13
0
        public void Visit(Conjunction visitable)
        {
            var nandRoot = new Negation();
            var nandLeft = new Nand();

            InsertNodeSingle(nandLeft, visitable.LeftNode);
            InsertNodeSingle(nandLeft, visitable.RightNode);
            BinaryTree.InsertNode(nandRoot, nandLeft);

            Calculate(nandRoot);

            BinaryTree.Root = nandRoot.Nand;
            visitable.Nand  = nandRoot.Nand;
        }
Beispiel #14
0
        public IParameter GetParameter()
        {
            Junction junc = new Conjunction();

            if (Type == JunctionType.Disjunction)
            {
                junc = new Disjunction();
            }
            foreach (var v in this)
            {
                junc.Add(v.GetParameter());
            }
            return(junc);
        }
Beispiel #15
0
        /// <summary>
        /// Gets a string representation of the given conjunction.
        /// </summary>
        /// <param name="conjunction">The conjunction to convert to a string.</param>
        /// <returns>The string representation.</returns>
        public string ToString(Conjunction conjunction)
        {
            switch (conjunction)
            {
            case Conjunction.And:
                return("AND");

            case Conjunction.Or:
                return("OR");

            default:
                throw new ArgumentException("Encountered an unknown conjunction type.");
            }
        }
Beispiel #16
0
        public IDictionary <string, IList <Entity_Student> > filteredStudentList(MyCriteria notifyCriteria)
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(NotificationManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria mainCriteria = DetachedCriteria.For <Entity_Student>("student");

            mainCriteria.CreateAlias("scoreObj", "score");
            Conjunction conjunction = Restrictions.Conjunction();

            conjunction.Add(Restrictions.Eq("student.myConfigObj.currentBatch", notifyCriteria.batch));
            conjunction.Add(Restrictions.Eq("student.myConfigObj.currentDegree", notifyCriteria.degree));
            conjunction.Add(Restrictions.Ge("score.X", notifyCriteria.X));
            conjunction.Add(Restrictions.Ge("score.cgpa", notifyCriteria.cgpa));
            conjunction.Add(Restrictions.Le("score.arrears", notifyCriteria.arrears));
            conjunction.Add(Restrictions.In("student.branch", notifyCriteria.branch));

            if (notifyCriteria.isDiplomaAllowed)
            {
                Disjunction disjunction = Restrictions.Disjunction();
                disjunction.Add(Restrictions.Ge("score.XII", notifyCriteria.XII));
                disjunction.Add(Restrictions.Ge("score. ", notifyCriteria.XII));

                conjunction.Add(disjunction);
            }
            else
            {
                conjunction.Add(Restrictions.Ge("score.XII", notifyCriteria.XII));
            }

            mainCriteria.Add(conjunction);

            if (!notifyCriteria.isPlaced)
            {
                DetachedCriteria subCriteria = DetachedCriteria.For <Entity_PlacementDetails>("placedObj");
                subCriteria.Add(Restrictions.EqProperty("placedObj.studentId", "student.studentId"));
                subCriteria.SetProjection(Projections.Distinct(Projections.Property("placedObj.studentId")));
                mainCriteria.Add(Subqueries.NotExists(subCriteria));
            }

            IList list = persistence.findByCriteria(mainCriteria);

            if (list != null && list.Count > 0)
            {
                IDictionary <string, IList <Entity_Student> > eligibleStudentMap = prepareStudentList(list.Cast <Entity_Student>().ToList());
                return(eligibleStudentMap);
            }
            else
            {
                return(null);
            }
        }
Beispiel #17
0
        public static ICriterion IntersectCriterions(params ICriterion[] crits)
        {
            IList <ICriterion> list        = crits.ToList <ICriterion>();
            Conjunction        conjunction = new Conjunction();

            foreach (ICriterion criterion in list)
            {
                if (criterion != null)
                {
                    conjunction.Add(criterion);
                }
            }
            return(conjunction);
        }
Beispiel #18
0
        public void GraphPlanTest_Robot()
        {
            EntitySet objects = new EntitySet();

            objects.addObject("green", "Color");
            objects.addObject("red", "Color");
            objects.addObject("sec1", "Section");

            Conjunction init = new Conjunction("CurrentColor (green)");
            Conjunction goal = new Conjunction("Painted (sec1, red)");

            OperatorHead opPaintHead = new OperatorHead("Paint", new ParaList("Section ?sec, Color ?clr"));
            Condition    opPaintCond = new Condition("");
            Conjunction  opPaintPre  = new Conjunction("CurrentColor (?clr)");
            Conjunction  opPaintAdd  = new Conjunction("Painted (?sec, ?clr)");
            Conjunction  opPaintDel  = new Conjunction("");
            Operator     opPaint     = new Operator(opPaintHead, opPaintCond, opPaintPre, opPaintAdd, opPaintDel);

            OperatorHead opChangeColorHead = new OperatorHead("ChangeColor", new ParaList("Color ?old, Color ?new"));
            Condition    opChangeColorCond = new Condition("?old != ?new");
            Conjunction  opChangeColorPre  = new Conjunction("CurrentColor (?old)");
            Conjunction  opChangeColorAdd  = new Conjunction("CurrentColor (?new)");
            Conjunction  opChangeColorDel  = new Conjunction("CurrentColor (?old)");
            Operator     opChangeColor     = new Operator(opChangeColorHead, opChangeColorCond, opChangeColorPre, opChangeColorAdd, opChangeColorDel);

            OperatorSet opSet = new OperatorSet();

            opSet.Operators.Add(opPaint);
            opSet.Operators.Add(opChangeColor);

            GraphPlan graph = new GraphPlan(objects, init, goal, opSet);
            bool      res   = graph.CreateGraph();

            Assert.IsTrue(res);

            res = graph.SearchGoal();
            Assert.IsTrue(res);

            List <string> plan = graph.GetPlan();

            //foreach (string step in plan)
            //{
            //    System.Console.WriteLine(step);
            //}

            Assert.AreEqual(2, plan.Count);

            Assert.AreEqual("ChangeColor ( green, red )", plan[0]);
            Assert.AreEqual("Paint ( sec1, red )", plan[1]);
        }
        public void TestDNFIdempotence()
        {
            Conjunction conj1 = new Conjunction(A, Aneg);
            Disjunction disj1 = new Disjunction(conj1, Bneg, Dneg, E);
            Conjunction conj2 = new Conjunction(A, Dneg, disj1);

            BooleanExpression actual   = conj2.ToDNF().ToDNF();
            BooleanExpression expected = conj2.ToDNF();

            Assert.Equal(expected, actual);

            Assert.True(actual.Is_DNF());
            Assert.True(expected.Is_DNF());
        }
Beispiel #20
0
        public Constraint And([NotNull] Constraint other)
        {
            switch (CompareImpl(other) ?? Invert(other.CompareImpl(this)))
            {
            case CompareOutcome.Looser:
                return(other);

            case CompareOutcome.Stricter:
                return(this);

            default:
                return(Conjunction.From(this, other));
            }
        }
        protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
        {
            if (elementName == "accessControl")
            {
                XmlSerializer ser = new XmlSerializer(typeof(Conjunction));
                this.AccessControl = ser.Deserialize(reader) as Conjunction;

                return true;
            }
            else
            {
                return false;
            }
        }
        private string _LocalizeList <T>(Conjunction conjunction, IEnumerable <T> values, Func <T, string> strFunc)
        {
            int count = values.Count();

            if (count == 0)
            {
                return("");
            }
            else if (count == 1)
            {
                return(strFunc(values.ElementAt(0)));
            }
            else if (count == 2)
            {
                return(Localizer.Format(conjunction == Conjunction.AND ? "#cc.list.and.2" : "#cc.list.or.2", strFunc(values.ElementAt(0)), strFunc(values.ElementAt(1))));
            }
            else
            {
                StringBuilder sb = StringBuilderCache.Acquire(count * 16);

                int    i    = 0;
                string prev = null;
                foreach (T tval in values)
                {
                    string val = strFunc(tval);
                    if (i == 0)
                    {
                        prev = val;
                    }
                    else if (i == 1)
                    {
                        sb.Append(Localizer.Format(conjunction == Conjunction.AND ? "#cc.list.and.start" : "#cc.list.or.start", prev, val));
                    }
                    else if (i != count - 1)
                    {
                        sb.Append(conjunction == Conjunction.AND ? andMiddle : orMiddle);
                        sb.Append(val);
                    }
                    else
                    {
                        sb.Append(conjunction == Conjunction.AND ? andEnd : orEnd);
                        sb.Append(val);
                    }
                    i++;
                }

                return(sb.ToStringAndRelease());
            }
        }
Beispiel #23
0
        public void ThrowExceptionWhenBillCanNotBeGetByCriteriaBecauseDatabaseNotConnected()
        {
            // Arrange
            this.CreateRepository();

            Conjunction conjunction = Restrictions.Conjunction();

            conjunction.Add(Restrictions.Where <Bill>(bill => bill.Date.IsLike("23", MatchMode.Anywhere)));

            // Act
            Action action = () => this._repository.GetByCriteria <Bill>(conjunction, 1);

            // Assert
            action.ShouldThrow <NullReferenceException>();
        }
        public void TestMultiOperatorFormula1()
        {
            Conjunction conj = new Conjunction(new Negation(C),
                                               B);
            BooleanExpression formula = new Disjunction(new Negation(new Disjunction(new Negation(A), B)),
                                                        conj);
            BooleanExpression actual = formula.ToDNF();

            BooleanExpression expected = new Disjunction(new Conjunction(A, new Negation(B)),
                                                         new Conjunction(new Negation(C), B));

            Assert.True(actual.Is_DNF());
            Assert.True(expected.Is_DNF());
            Assert.Equal(expected, actual);
        }
Beispiel #25
0
        private void VisitAndAlsoExpression(BinaryExpression expr)
        {
            criterionStack.Push(new List <ICriterion>());
            Visit(expr.Left);
            Visit(expr.Right);
            var ands = criterionStack.Pop();

            var conjunction = new Conjunction();

            foreach (var crit in ands)
            {
                conjunction.Add(crit);
            }
            CurrentCriterions.Add(conjunction);
        }
Beispiel #26
0
        public void ThrowExceptionWhenClientCanNotBeGetByCriteriaBecauseDatabaseNotConnected()
        {
            // Arrange
            this.CreateRepository();

            Conjunction conjunction = Restrictions.Conjunction();

            conjunction.Add(Restrictions.Where <Client>(client => client.FirstName.IsLike("test")));

            // Act
            Action action = () => this._repository.GetByCriteria <Client>(conjunction, 1);

            // Assert
            action.ShouldThrow <NullReferenceException>();
        }
Beispiel #27
0
        protected override Junction SetupWhere(ApplicationQuery request)
        {
            var junction = new Conjunction();

            if (!string.IsNullOrEmpty(request.InGameName))
            {
                junction.Add(Restrictions.Where(() => RootAlias.InGameName == request.InGameName));
            }

            if (request.Status.HasValue)
            {
                junction.Add(Restrictions.Where(() => RootAlias.Status == request.Status.Value));
            }

            return(junction);
        }
Beispiel #28
0
        public void Replace_ReplacingExistingBoundVariableInComplexExpression_ShouldReturnTrueForChildrenContainingReplacedVariable()
        {
            // Arrange
            char variableToBeReplaced = 'w';

            List <char> variablesSetOne = new List <char>()
            {
                'u',
                variableToBeReplaced
            };

            // Does not contain the replacement variable
            List <char> variablesSetTwo = new List <char>()
            {
                'v',
                'x'
            };

            Predicate predicateWithReplacementVariable = new Predicate(PREDICATE_SYMBOL, variablesSetOne);
            // So we have unique references
            Predicate predicateWithoutReplacementVariableOne = new Predicate(PREDICATE_SYMBOL, variablesSetTwo);
            Predicate predicateWithoutReplacementVariableTwo = new Predicate(PREDICATE_SYMBOL, variablesSetTwo);

            BinaryConnective root     = new Conjunction();
            BinaryConnective rootLeft = new BiImplication();

            rootLeft.LeftSuccessor  = predicateWithoutReplacementVariableOne;
            rootLeft.RightSuccessor = predicateWithReplacementVariable;

            root.LeftSuccessor  = rootLeft;
            root.RightSuccessor = predicateWithoutReplacementVariableTwo;


            char replacementVariable = 'c';

            // Act
            root.Replace(variableToBeReplaced, replacementVariable);

            bool isReplacedOnPredicateWithVariable       = predicateWithReplacementVariable.IsReplaced(variableToBeReplaced);
            bool isReplacedOnPredicateWithoutVariableOne = predicateWithoutReplacementVariableOne.IsReplaced(variableToBeReplaced);
            bool isReplacedOnPredicateWithoutVariableTwo = predicateWithoutReplacementVariableTwo.IsReplaced(variableToBeReplaced);

            // Assert
            isReplacedOnPredicateWithVariable.Should().BeTrue($"Since the bound variable {variableToBeReplaced} should be repalced replaced by {replacementVariable}");
            isReplacedOnPredicateWithoutVariableOne.Should().BeFalse($"Since the predicate does NOT contain {variableToBeReplaced}");
            isReplacedOnPredicateWithoutVariableTwo.Should().BeFalse($"Since the predicate does NOT contain {variableToBeReplaced}");
        }
Beispiel #29
0
        public void GraphPlanTest_Blocks()
        {
            EntitySet objects = new EntitySet();

            objects.addObject("b1", "Block");
            objects.addObject("b2", "Block");
            objects.addObject("b3", "Block");
            objects.addObject("Table", "Block");

            Conjunction init = new Conjunction("ON (b1, b2) & ON (b2, Table) & ON (b3, Table) & Clear (b1) & Clear (b3) & Clear (Table)");
            Conjunction goal = new Conjunction("ON (b3, Table) & ON (b2, b3) & ON (b1, b2)");

            OperatorHead opMoveHead = new OperatorHead("Move", new ParaList("Block ?obj, Block ?from, Block ?to"));
            Condition    opMoveCond = new Condition("?obj != ?from & ?obj != ?to & ?from != ?to & ?to != Table");
            Conjunction  opMovePre  = new Conjunction("ON (?obj, ?from) & Clear (?obj) & Clear (?to)");
            Conjunction  opMoveAdd  = new Conjunction("ON (?obj, ?to) & Clear (?from)");
            Conjunction  opMoveDel  = new Conjunction("ON (?obj, ?from) & Clear (?to)");
            Operator     opMove     = new Operator(opMoveHead, opMoveCond, opMovePre, opMoveAdd, opMoveDel);

            OperatorHead opMoveToTableHead = new OperatorHead("MoveToTable", new ParaList("Block ?obj, Block ?from"));
            Condition    opMoveToTableCond = new Condition("?obj != ?from & ?obj != Table & ?from != Table");
            Conjunction  opMoveToTablePre  = new Conjunction("Clear (?obj) & ON (?obj, ?from)");
            Conjunction  opMoveToTableAdd  = new Conjunction("ON (?obj, Table) & Clear (?from)");
            Conjunction  opMoveToTableDel  = new Conjunction("ON (?obj, ?from)");
            Operator     opMoveToTable     = new Operator(opMoveToTableHead, opMoveToTableCond, opMoveToTablePre, opMoveToTableAdd, opMoveToTableDel);

            OperatorSet opSet = new OperatorSet();

            opSet.Operators.Add(opMove);
            opSet.Operators.Add(opMoveToTable);

            GraphPlan graph = new GraphPlan(objects, init, goal, opSet);
            bool      res   = graph.CreateGraph();

            Assert.IsTrue(res);

            res = graph.SearchGoal();
            Assert.IsTrue(res);

            List <string> plan = graph.GetPlan();

            Assert.AreEqual(3, plan.Count);

            Assert.AreEqual("MoveToTable ( b1, b2 )", plan[0]);
            Assert.AreEqual("Move ( b2, Table, b3 )", plan[1]);
            Assert.AreEqual("Move ( b1, Table, b2 )", plan[2]);
        }
Beispiel #30
0
        ////////////////////////////////////////////////////////////
        public void andWith(PropositionalFormula other)
        {
            List <Conjunction> oldDisjuncts = myDisjuncts;

            myDisjuncts = new List <Conjunction>();
            foreach (var cx in oldDisjuncts)
            {
                foreach (var cy in other.myDisjuncts)
                {
                    Conjunction a = cx & cy;
                    if (a != null)
                    {
                        checkAddDisjunct(a);
                    }
                }
            }
        }
Beispiel #31
0
        public static QueryBuilder <T> operator !(QueryBuilder <T> other)
        {
            QueryBuilder <T> not = new QueryBuilder <T>(other.myName, null);

            if (other.children.Count != 0)
            {
                throw new InvalidOperationException("Cannot use ! operator on complex queries");
            }
            Conjunction conjunction = new Conjunction();

            foreach (ICriterion crit in other.criterions)
            {
                conjunction.Add(crit);
            }
            not.AddCriterion(Expression.Not(conjunction));
            return(not);
        }
Beispiel #32
0
 /// <summary>
 /// Initializes a new instance of a FilterGroup.
 /// </summary>
 public FilterGroup(Conjunction conjunction = Conjunction.And, params IFilter[] filters)
 {
     if (!Enum.IsDefined(typeof(Conjunction), conjunction))
     {
         throw new ArgumentException("Invalid enum", "conjunction");
     }
     if (filters == null)
     {
         throw new ArgumentNullException("filters");
     }
     _conjunction = conjunction;
     _filters     = new List <IFilter>();
     foreach (IFilter filter in filters)
     {
         AddFilter(filter);
     }
 }
        public override ICriterion GetCondition()
        {
            var          conjunction       = new Conjunction();
            BookHeadword bookHeadwordAlias = null;

            foreach (var criteria in m_criteriaList)
            {
                var disjunction = new Disjunction();
                foreach (var conditionString in criteria.Disjunctions)
                {
                    disjunction.Add(new LikeExpression(Projections.Property(() => bookHeadwordAlias.Headword), conditionString, MatchMode.Exact));
                }
                conjunction.Add(disjunction);
            }

            return(conjunction);
        }
Beispiel #34
0
        public void ConjunctionionTest_Intersect()
        {
            string      literal1 = "ON (b3, Table) & ON (b2, b3) & ON (b1, b2)";
            Conjunction conj1    = new Conjunction(literal1);

            string      literal2 = "ON (b1, b2) & ON (b2, b3) & ON (b3, Table)";
            Conjunction conj2    = new Conjunction(literal2);

            Assert.IsTrue(conj1.Intersect(conj2));
            Assert.IsTrue(conj2.Intersect(conj1));

            string      literal3 = "ON (b1, b3) & Clear (Table) & Clear (b1)";
            Conjunction conj3    = new Conjunction(literal3);

            Assert.IsFalse(conj1.Intersect(conj3));
            Assert.IsFalse(conj3.Intersect(conj1));
        }
Beispiel #35
0
 /// <summary>
 /// Initializes a new instance of a FilterGroup.
 /// </summary>
 public FilterGroup(Conjunction conjunction = Conjunction.And, params IFilter[] filters)
 {
     if (!Enum.IsDefined(typeof(Conjunction), conjunction))
     {
         throw new InvalidEnumArgumentException("conjunction", (int)conjunction, typeof(Conjunction));
     }
     if (filters == null)
     {
         throw new ArgumentNullException("filters");
     }
     _conjunction = conjunction;
     _filters = new List<IFilter>();
     foreach (IFilter filter in filters)
     {
         AddFilter(filter);
     }
 }
Beispiel #36
0
 public double Satisfy (State s, Conjunction conjunct)
 {
     return conjunct.Expressions.Select (x => Satisfy (s, x)).Aggregate (1d, (acc, val) => acc * val);
 }