示例#1
0
        /// <summary>
        /// Interpretation plan operations implementing the
        /// CheckCondition search plan operation
        /// are created and inserted into the interpretation plan at the insertion point
        /// </summary>
        private void buildCondition(
            InterpretationPlan insertionPoint, int index,
            PatternCondition condition)
        {
            // check condition
            expression.AreAttributesEqual aae = (expression.AreAttributesEqual)condition.ConditionExpression;
            foreach (SearchPlanNode spn in spg.Nodes)
            {
                if (spn.PatternElement == aae.thisInPattern)
                {
                    InterpretationPlanCheckCondition checkCondition;
                    if (spn is SearchPlanNodeNode)
                    {
                        SearchPlanNodeNode nodeNode = (SearchPlanNodeNode)spn;
                        checkCondition = new InterpretationPlanCheckCondition(
                            aae, nodeNode.nodeMatcher, Array.IndexOf(aae.thisInPattern.pointOfDefinition.nodes, aae.thisInPattern));
                    }
                    else
                    {
                        SearchPlanEdgeNode edgeNode = (SearchPlanEdgeNode)spn;
                        checkCondition = new InterpretationPlanCheckCondition(
                            aae, edgeNode.edgeMatcher, Array.IndexOf(aae.thisInPattern.pointOfDefinition.edges, aae.thisInPattern));
                    }

                    checkCondition.prev = insertionPoint;
                    insertionPoint.next = checkCondition;
                    insertionPoint      = insertionPoint.next;

                    // continue with next operation
                    BuildInterpretationPlan(insertionPoint, index + 1);
                    return;
                }
            }
            throw new Exception("Internal error constructing interpretation plan!");
        }
 public void TestNoPatterns()
 {
     using (var e = new MockA11yElement())
     {
         var test = new PatternCondition(PatternIDs.Toggle);
         Assert.IsFalse(test.Matches(e));
     } // using
 }
 public void TestNonMatchingPatternIDs()
 {
     using (var e = new MockA11yElement())
     {
         e.Patterns.Add(new A11yPattern(e, PatternIDs.Invoke));
         var test = new PatternCondition(PatternIDs.ExpandCollapse);
         Assert.IsFalse(test.Matches(e));
     } // using
 }