コード例 #1
0
        ///
        ///	 <summary> * Inverts the boolean state of a Term child element (and, or, xor, not,
        ///	 * Evaluation, TestRef)
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean “not” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;
            bool     b   = false;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("not");
            }

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                b = !t.fitsJDF(jdf, reportRootLocal);
                count++;
                if (reportRootLocal != null)
                {
                    reportRootLocal.setAttribute("Value", b, null);
                }
            }

            if (reportRootLocal != null && count != 1)
            {
                reportRootLocal.setAttribute("SyntaxWarning", "Warning: not element with more than one term, count=" + Convert.ToString(count));
            }

            return(b);
        }
コード例 #2
0
ファイル: JDFTest.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates the boolean expression (child Term element) if it fits the
        ///	 * JDFNode 'jdf' a value of true corresponds to a failed test, i.e. the test
        ///	 * describes INVALID states for the jdf
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate. Set to <code>null</code> if no report
        ///	 *            is requested. </param>
        ///	 * <returns> boolean - true, if boolean expression (child Term element)
        ///	 *         evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("TestReport");
            }
            JDFTerm t = getTerm();

            if (t == null)
            {
                return(true); // no term --> assume it is a non test; i.e. ok
            }
            bool checkContext = true;

            if (hasAttribute(AttributeName.CONTEXT))
            {
                checkContext = !jdf.matchesPath(getContext(), true);
            }
            if (checkContext && !t.fitsContext(jdf))
            {
                return(true);
            }
            bool b = t.fitsJDF(jdf, reportRootLocal);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }
            return(b);
        }
コード例 #3
0
ファイル: JDFor.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “or” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode we test iot know if the Device can accept it </param>
        ///	 * <returns> boolean - true, if boolean “or” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v   = getTermVector(null);
            int      siz = v.Count;

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("or");
            }

            bool b = false;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (b2 && reportRootLocal == null)
                {
                    return(true); // don't need complete report and it is true; ciao
                }
                b = b || b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
コード例 #4
0
ファイル: JDFxor.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more Term elements (and, or, xor, not, Evaluation,
        ///	 * TestRef) to determine if, as a set, they evaluate to “true” when combined
        ///	 * in a boolean “xor” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDFNode to test to know if the Device can accept it </param>
        ///	 * <param name="reportRoot">
        ///	 *            the report to generate; set to <code>null</code> if no report
        ///	 *            is requested </param>
        ///	 * <returns> boolean - true, if boolean “xor” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot)
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("xor");
            }

            int siz = v.Count;

            int count = 0;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t = (JDFTerm)v[i];
                if (t.fitsJDF(jdf, reportRootLocal))
                {
                    count++;
                }

                if (count > 1 && reportRootLocal == null)
                {
                    break;
                }
            }

            bool b = (count == 1);

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }
コード例 #5
0
ファイル: JDFand.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Evaluates two or more term elements (
        ///	 * <code>and, or, xor, not, Evaluation, TestRef</code>) to determine if, as
        ///	 * a set, they evaluate to “true” when combined in a boolean “and” function.
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            the JDFNode to be checked iot find out if the device can
        ///	 *            accept it </param>
        ///	 * <returns> boolean - true, if boolean “and” expression evaluates to “true” </returns>
        ///
        public override bool fitsJDF(KElement jdf, KElement reportRoot) // const JDFNode
        {
            KElement reportRootLocal = reportRoot;

            VElement v = getTermVector(null);

            if (reportRootLocal != null)
            {
                reportRootLocal = reportRootLocal.appendElement("and");
            }

            int  siz = v.Count;
            bool b   = true;

            for (int i = 0; i < siz; i++)
            {
                JDFTerm t  = (JDFTerm)v[i];
                bool    b2 = t.fitsJDF(jdf, reportRootLocal);
                if (!b2)
                {
                    if (reportRootLocal == null)
                    {
                        return(false);
                    }
                }

                b = b && b2;
            }

            if (reportRootLocal != null)
            {
                reportRootLocal.setAttribute("Value", b, null);
            }

            return(b);
        }