Exemplo n.º 1
0
        public override bool IsSatisfied(IEnumerable<XmlNodeInformation> lookahead, XmlFilterBase filter)
        {
            string currentPath = String.Empty;
            int? startDepth = null;

            if (filter is InkAnnotationXmlFilter)
            {
                m_target = (filter as InkAnnotationXmlFilter).Target;
            }
            else
            {
                m_target = null;
            }

            foreach (XmlNodeInformation xni in lookahead)
            {
                if (!startDepth.HasValue)
                {
                    startDepth = xni.Depth;
                }
                else if (xni.Depth < startDepth.Value)
                {
                    break;
                }

                switch (xni.NodeType)
                {
                    case NodeType.start:
                        currentPath += "/" + xni.LocalName;
                        break;
                    case NodeType.end:
                        int index = currentPath.LastIndexOf("/");
                        if (index != -1)
                        {
                            currentPath = currentPath.Substring(0, index);
                        }
                        break;
                }

                if (currentPath == "/ink" && xni.Prefix == "o")
                {
                    return (xni.GetAttributeValue("annotation") == "t");
                }

                if (xni.Prefix == "inkml")
                {
                    return true;
                }

                if (xni.EmptyElement)
                {
                    int index = currentPath.LastIndexOf("/");
                    if (index != -1)
                    {
                        currentPath = currentPath.Substring(0, index);
                    }
                }
            }
            return false;
        }
Exemplo n.º 2
0
        public List<TriggeringNodeDefinition> WhatDoesThisNodeTrigger(XmlNodeInformation NodeInfo, IEnumerable<XmlNodeInformation> lookaheadEnum, XmlFilterBase filter)
        {
            List<TriggeringNodeDefinition> subSet = LookupSubset(NodeInfo.NodeName);

            if (subSet == null)
                return null;

            return ExtractFiredTriggersFromTriggerList(NodeInfo, lookaheadEnum, subSet, filter);
        }
Exemplo n.º 3
0
 public override bool IsSatisfied(IEnumerable<XmlNodeInformation> lookahead, XmlFilterBase filter)
 {
     Reset();
     foreach (XmlNodeInformation xni in lookahead)
     {
         ProcessNode(xni);
         if (finished)
             return result && IsNotExcluded(filter.ExcludeList);
     }
     return result && IsNotExcluded(filter.ExcludeList);
 }
Exemplo n.º 4
0
        public List<TriggeringNodeDefinition> ExtractFiredTriggersFromTriggerList(XmlNodeInformation NodeInfo, IEnumerable<XmlNodeInformation> lookaheadEnum, List<TriggeringNodeDefinition> subSet, XmlFilterBase filter)
        {
            List<TriggeringNodeDefinition> results = new List<TriggeringNodeDefinition>();

            foreach (TriggeringNodeDefinition tnd in subSet)
            {
                if (tnd.nodeName == null && tnd.attributeFilter == null)
                    continue;  // safety net

                if (!NodeInfo.Is(tnd.namespaceId, tnd.nodeName))
                    continue;


                if (!tnd.attributeFilter.Matches(NodeInfo))
                    continue;

				Stack<bool> states;
                if (tnd.lookaheadFilter != null && lookaheadEnum != null)
                {
                    bool lookaheadSatisfied = tnd.lookaheadFilter.IsSatisfied(lookaheadEnum, filter);
                    if (!string.IsNullOrEmpty(tnd.LookAheadTrackingKey))
                    {
						if (!m_lookaheadStates.TryGetValue(tnd.LookAheadTrackingKey, out states))
						{
							states = new Stack<bool>();
							m_lookaheadStates.Add(tnd.LookAheadTrackingKey, states);
						}
                        states.Push(lookaheadSatisfied);
                    }
                    if (!lookaheadSatisfied)
                        continue;
                }
                else if (!string.IsNullOrEmpty(tnd.LookAheadTrackingKey))
                {
                    // depends on a lookahead value
                    if (!m_lookaheadStates.TryGetValue(tnd.LookAheadTrackingKey, out states))
                        continue;
					if (states.Count == 0)
                        continue;
					bool value = (tnd.PopsLookAheadValue ? states.Pop() : states.Peek());
                    if (!value)
                        continue;
                }

                results.Add(tnd);

            }
            return results;
        }
Exemplo n.º 5
0
        public override bool IsSatisfied(IEnumerable<XmlNodeInformation> lookahead, XmlFilterBase filter)
        {
            string currentPath = String.Empty;
            int? startDepth = null;

            foreach (XmlNodeInformation xni in lookahead)
            {
                if (!startDepth.HasValue)
                {
                    startDepth = xni.Depth;
                }
                else if (xni.Depth <= startDepth.Value)
                {
                    break;
                }

                switch (xni.NodeType)
                {
                    case NodeType.start:
                        currentPath += "/" + xni.LocalName;
                        break;
                    case NodeType.end:
						int index = currentPath.LastIndexOf("/");
						if ( index != -1 )
						{
							currentPath = currentPath.Substring(0, index);
						}
                        break;
                }

                if (currentPath == m_notQuiteXPath) 
                    return true;

                if (xni.EmptyElement)
                {
                    int index = currentPath.LastIndexOf("/");
                    if (index != -1)
                    {
                        currentPath = currentPath.Substring(0, index);
                    }
                }

            }
            return false;
        }
Exemplo n.º 6
0
 public abstract bool IsSatisfied(IEnumerable<XmlNodeInformation> lookahead, XmlFilterBase filter);
Exemplo n.º 7
0
 public List<TriggeringNodeDefinition> WhatDoesThisNodeTrigger(XmlNodeInformation NodeInfo, XmlFilterBase filter)
 {
     return WhatDoesThisNodeTrigger(NodeInfo, null, filter);
 }