当前位置: 首页>>代码示例>>C#>>正文


C# XPathNavigator.IsSamePosition方法代码示例

本文整理汇总了C#中System.Xml.XPath.XPathNavigator.IsSamePosition方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.IsSamePosition方法的具体用法?C# XPathNavigator.IsSamePosition怎么用?C# XPathNavigator.IsSamePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XPath.XPathNavigator的用法示例。


在下文中一共展示了XPathNavigator.IsSamePosition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InStk

 private int InStk(XPathNavigator temp){
     int flag = 0;
     for(int i= 0;i< _AncestorStk.Count; i++){
         if (temp.IsSamePosition((XPathNavigator)_AncestorStk[i])){
             if (i == _AncestorStk.Count - 1)
                 flag = 2;
             _AncestorStk.RemoveAt(i);
             return flag;
         }
     }
     return 1;
 }
开发者ID:ArildF,项目名称:masters,代码行数:12,代码来源:precedingquery.cs

示例2: Add

        /// <summary>
        /// Add a node indexed by the specified key value.
        /// </summary>
        public void Add(string key, XPathNavigator navigator) {
            XmlQueryNodeSequence seq;

            if (!this.table.TryGetValue(key, out seq)) {
                // Create a new sequence and add it to the index
                seq = new XmlQueryNodeSequence();
                seq.AddClone(navigator);
                this.table.Add(key, seq);
            }
            else {
                // The nodes are guaranteed to be added in document order with possible duplicates.
                // Add node to the existing sequence if it differs from the last one.
                Debug.Assert(navigator.ComparePosition(seq[seq.Count - 1]) >= 0, "Index nodes must be added in document order");
                if (!navigator.IsSamePosition(seq[seq.Count - 1])) {
                    seq.AddClone(navigator);
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:21,代码来源:XmlILIndex.cs

示例3: Add

        /// <summary>
        /// Add a node indexed by the specified key value.
        /// </summary>
        public void Add(string key, XPathNavigator navigator) {
            XmlQueryNodeSequence seq = (XmlQueryNodeSequence) this.table[key];

            if (seq == null) {
                // Create a new sequence and add it to the index
                seq = new XmlQueryNodeSequence();
                seq.AddClone(navigator);
                this.table.Add(key, seq);
            }
            else {
                // Add node to existing sequence; don't add if it already there
                for (int i = 0; i < seq.Count; i++) {
                    if (navigator.IsSamePosition(seq[i]))
                        return;
                }

                seq.AddClone(navigator);
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:22,代码来源:xmlilindex.cs

示例4: Remove

		/// <summary>
		/// Removes the first occurrence of a specific object from the list.
		/// </summary>
		/// <param name="value">The object to remove from the list.</param>
		public void Remove(XPathNavigator nav){
		
			for(int i = 0; i < this.Count; i++){
				if(nav.IsSamePosition((XPathNavigator) this.innerList[i])){
					this.innerList.RemoveAt(i); 
					return; 
				} 
			}
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:13,代码来源:ExsltNodeList.cs

示例5: MoveToFollowing

		virtual bool MoveToFollowing (XPathNodeType type,
			XPathNavigator end)
		{
			if (type == XPathNodeType.Root)
				return false; // will never match
			XPathNavigator nav = Clone ();
			switch (nav.NodeType) {
			case XPathNodeType.Attribute:
			case XPathNodeType.Namespace:
				nav.MoveToParent ();
				break;
			}
			do {
				if (!nav.MoveToFirstChild ()) {
					do {
						if (!nav.MoveToNext ()) {
							if (!nav.MoveToParent ())
								return false;
						}
						else
							break;
					} while (true);
				}
				if (end != null && end.IsSamePosition (nav))
					return false;
				if (type == XPathNodeType.All || nav.NodeType == type) {
					MoveTo (nav);
					return true;
				}
			} while (true);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:31,代码来源:XPathNavigator.cs

示例6: Create

        /// <summary>
        /// Initialize the NodeRangeIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator start, XmlNavigatorFilter filter, XPathNavigator end) {
            // Save start node as current node and save ending node
            this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, start);
            this.navEnd = XmlQueryRuntime.SyncToNavigator(this.navEnd, end);
            this.filter = filter;

            if (start.IsSamePosition(end)) {
                // Start is end, so only return node if it is not filtered
                this.state = !filter.IsFiltered(start) ? IteratorState.HaveCurrentNoNext : IteratorState.NoNext;
            }
            else {
                // Return nodes until end is reached
                this.state = !filter.IsFiltered(start) ? IteratorState.HaveCurrent : IteratorState.NeedCurrent;
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:18,代码来源:treeiterators.cs

示例7: Create

        /// <summary>
        /// Initialize the PrecedingIterator (no possibility of duplicates).
        /// </summary>
        public void Create(XPathNavigator context, XmlNavigatorFilter filter)
        {
            // Start at root, which is always first node in the document
            _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context);
            _navCurrent.MoveToRoot();
            _stack.Reset();

            // If root node is not the ending node,
            if (!_navCurrent.IsSamePosition(context))
            {
                // Push root onto the stack if it is not filtered
                if (!filter.IsFiltered(_navCurrent))
                    _stack.Push(_navCurrent.Clone());

                // Push all matching nodes onto stack
                while (filter.MoveToFollowing(_navCurrent, context))
                    _stack.Push(_navCurrent.Clone());
            }
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:22,代码来源:TreeIterators.cs

示例8: MatchNode

        public override XPathNavigator MatchNode(XPathNavigator current) {
            XPathNavigator context;
            if (current == null) {
                return null;
            }
            context = qyInput.MatchNode(current);

            if (context != null) {
                // In this switch we process some special case in wich we can calculate predicate faster then in generic case
                switch (cond.StaticType) {
                case XPathResultType.Number:
                    OperandQuery operand = cond as OperandQuery;
                    if (operand != null) {
                        double val = (double)operand.val;
                        ChildrenQuery childrenQuery = qyInput as ChildrenQuery;
                        if (childrenQuery != null) { // foo[2], but not foo[expr][2]
                            XPathNavigator result = current.Clone();
                            result.MoveToParent();
                            int i = 0;
                            result.MoveToFirstChild();
                            do {
                                if (childrenQuery.matches(result)) {
                                    i++;
                                    if (current.IsSamePosition(result)) {
                                        return val == i ? context : null;
                                    }
                                }
                            } while (result.MoveToNext());
                            return null;
                        }
                        AttributeQuery attributeQuery = qyInput as AttributeQuery;
                        if (attributeQuery != null) {// @foo[3], but not @foo[expr][2]
                            XPathNavigator result = current.Clone();
                            result.MoveToParent();
                            int i = 0;
                            result.MoveToFirstAttribute();
                            do {
                                if (attributeQuery.matches(result)) {
                                    i++;
                                    if (current.IsSamePosition(result)) {
                                        return val == i ? context : null;
                                    }
                                }
                            } while (result.MoveToNextAttribute());
                            return null;
                        }
                    }
                    break;
                case XPathResultType.NodeSet:
                    cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true));
                    return (cond.Advance() != null) ? context : null;
                case XPathResultType.Boolean:
                    if (noPosition) {
                        return ((bool)cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true))) ? context : null;
                    }
                    break;
                case XPathResultType.String:
                    if (noPosition) {
                        return (((string)cond.Evaluate(new XPathSingletonIterator(current, /*moved:*/true))).Length != 0) ? context : null;
                    }
                    break;
                case XPathResultType_Navigator:
                    return context;
                default:
                    return null;
                }
                /* Generic case */ {
                    Evaluate(new XPathSingletonIterator(context, /*moved:*/true));
                    XPathNavigator result;
                    while ((result = Advance()) != null) {
                        if (result.IsSamePosition(current)) {
                            return context;
                        }
                    }
                }
            }
            return null;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:78,代码来源:FilterQuery.cs

示例9: IsDescendant

 public virtual bool IsDescendant(XPathNavigator nav)
 {
     if (nav != null)
     {
         nav = nav.Clone();
         while (nav.MoveToParent())
         {
             if (nav.IsSamePosition(this))
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:XPathNavigator.cs

示例10: CompareSiblings

        private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2)
        {
            int num = 0;
            switch (n1.NodeType)
            {
                case XPathNodeType.Attribute:
                    num++;
                    break;

                case XPathNodeType.Namespace:
                    break;

                default:
                    num += 2;
                    break;
            }
            switch (n2.NodeType)
            {
                case XPathNodeType.Attribute:
                    num--;
                    if (num == 0)
                    {
                        while (n1.MoveToNextAttribute())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;

                case XPathNodeType.Namespace:
                    if (num == 0)
                    {
                        while (n1.MoveToNextNamespace())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;

                default:
                    num -= 2;
                    if (num == 0)
                    {
                        while (n1.MoveToNext())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;
            }
            if (num >= 0)
            {
                return XmlNodeOrder.After;
            }
            return XmlNodeOrder.Before;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:65,代码来源:XPathNavigator.cs

示例11: CompareSiblings

        // XPath based comparison for namespaces, attributes and other 
        // items with the same parent element.
        //
        //                 n2
        //                 namespace(0)    attribute(-1)   other(-2)
        // n1
        // namespace(0)    ?(0)            before(-1)      before(-2)
        // attribute(1)    after(1)        ?(0)            before(-1)
        // other    (2)    after(2)        after(1)        ?(0)
        private static XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2)
        {
            int cmp = 0;

#if DEBUG
            Debug.Assert(!n1.IsSamePosition(n2));
            XPathNavigator p1 = n1.Clone(), p2 = n2.Clone();
            Debug.Assert(p1.MoveToParent() && p2.MoveToParent() && p1.IsSamePosition(p2));
#endif
            switch (n1.NodeType)
            {
                case XPathNodeType.Namespace:
                    break;
                case XPathNodeType.Attribute:
                    cmp += 1;
                    break;
                default:
                    cmp += 2;
                    break;
            }
            switch (n2.NodeType)
            {
                case XPathNodeType.Namespace:
                    if (cmp == 0)
                    {
                        while (n1.MoveToNextNamespace())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;
                case XPathNodeType.Attribute:
                    cmp -= 1;
                    if (cmp == 0)
                    {
                        while (n1.MoveToNextAttribute())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;
                default:
                    cmp -= 2;
                    if (cmp == 0)
                    {
                        while (n1.MoveToNext())
                        {
                            if (n1.IsSamePosition(n2))
                            {
                                return XmlNodeOrder.Before;
                            }
                        }
                    }
                    break;
            }
            return cmp < 0 ? XmlNodeOrder.Before : XmlNodeOrder.After;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:72,代码来源:XPathNavigator.cs

示例12: MatchNode

        protected XPathNavigator MatchNode(XPathNavigator current, IQuery query) {
            XPathNavigator context;
            if (current != null) {
                context = query.MatchNode(current);
                if (context != null) {
                    if (_opnd.ReturnType() == XPathResultType.Number) {
                        if (_opnd.getName() == Querytype.Constant) {
                            XPathNavigator result = current.Clone();

                            int i=0;
                            if (query.getName() == Querytype.Child) {
                                result.MoveToParent();
                                result.MoveToFirstChild();
                                while (true) {
                                    if (((ChildrenQuery)query).matches(result)){
                                        i++;
                                    if (current.IsSamePosition(result))
                                        if (XmlConvert.ToXPathDouble(_opnd.getValue(current, null)) ==  i)
                                            return context;
                                        else
                                            return null;
                                    }        
                                    if (!result.MoveToNext())
                                        return null;

                                }
                            }
                            if (query.getName() == Querytype.Attribute) {
                                result.MoveToParent();
                                result.MoveToFirstAttribute();
                                while (true) {
                                    if (((AttributeQuery)query).matches(result))
                                        i++;
                                    if (current.IsSamePosition(result))
                                        if (XmlConvert.ToXPathDouble(_opnd.getValue(current, null)) == i)
                                            return context;
                                        else
                                            return null;
                                    if (!result.MoveToNextAttribute())
                                        return null;
                         
                                }
                            }
                        }
                        else {
                            setContext(context.Clone());
                            XPathNavigator result = advance();
                            while (result != null) {
                                if (result.IsSamePosition(current))
                                    return context;
                                result = advance();
                            }
                        }

                    }
                    if (_opnd.ReturnType() == XPathResultType.NodeSet) {
                        _opnd.setContext(current); 
                        if (_opnd.advance() != null)
                            return context;
                        else
                            return null;
                    }
                    if (_opnd.ReturnType() == XPathResultType.Boolean) {
                        if (noPosition) {
                            if ((bool)_opnd.getValue(current, null)) {
                                return context;
                            }
                            return null;
                        }
                        setContext(context.Clone());
                        XPathNavigator result = advance();
                        while (result != null) {
                            if (result.IsSamePosition(current))
                                return context;
                            result = advance();
                        }
                        return null;
                    }
                    if (_opnd.ReturnType() == XPathResultType.String)
                        if (_opnd.getValue(context, null).ToString().Length >0)
                            return context;
                        else
                            return null;

                }
                else
                    return null;
            }
            return null;
        } 
开发者ID:ArildF,项目名称:masters,代码行数:90,代码来源:filterquery.cs

示例13: Matches

		public override bool Matches (XPathNavigator node, XsltContext ctx)
		{
			if (! nodeTest.Match (ctx, node))
				return false;
			
			if (nodeTest is NodeTypeTest) {
				// node () is different in xslt patterns
				if (((NodeTypeTest)nodeTest).type == XPathNodeType.All && 
					(node.NodeType == XPathNodeType.Root ||
					node.NodeType == XPathNodeType.Attribute)
				)
				return false;
			}
			
			if (filter == null && patternPrevious == null)
				return true;
			
			XPathNavigator tmpNav;
			if (patternPrevious != null) {
				tmpNav = ((XsltCompiledContext) ctx).GetNavCache (this, node);
				if (!isAncestor) {
					tmpNav.MoveToParent ();
					if (!patternPrevious.Matches (tmpNav, ctx))
						return false;
				} else {
					while (true) {
						if (!tmpNav.MoveToParent ())
							return false;
						
						if (patternPrevious.Matches (tmpNav, ctx))
							break;
					}
				}
			}

						
			if (filter == null)
				return true;

			// Optimization for non-positional predicate
			if (!filter.IsPositional && !(filter.expr is ExprFilter)) {
				return filter.pred.EvaluateBoolean (new NullIterator (node, ctx));
			}

			tmpNav = ((XsltCompiledContext) ctx).GetNavCache (this, node);
			tmpNav.MoveToParent ();

			BaseIterator matches = filter.EvaluateNodeSet (new NullIterator (tmpNav, ctx));
			
			while (matches.MoveNext ()) {
				if (node.IsSamePosition (matches.Current))
					return true;
			}
			
			return false;
		}
开发者ID:nobled,项目名称:mono,代码行数:56,代码来源:LocationPathPattern.cs

示例14: CompareSiblings

 private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2){
     bool attr1 = n1.NodeType == XPathNodeType.Attribute;
     bool attr2 = n2.NodeType == XPathNodeType.Attribute;
     bool ns1 = n1.NodeType == XPathNodeType.Namespace;
     bool ns2 = n2.NodeType == XPathNodeType.Namespace;
     if (! ns1 && ! ns2 && ! attr1 && ! attr2) {
         while (n1.MoveToNext()) {
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (attr1 && attr2) {
         while (n1.MoveToNextAttribute()){
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (attr1){
         return XmlNodeOrder.After;
     }
     if (attr2){
         return XmlNodeOrder.Before;
     }
     if (ns1 && ns2) {
         while (n1.MoveToNextNamespace()) {
             if (n1.IsSamePosition(n2))
                 return XmlNodeOrder.Before;
         }
         return XmlNodeOrder.After;
     }
     if (ns1){
         return XmlNodeOrder.After;
     }
     Debug.Assert(ns2);
     return XmlNodeOrder.Before;
 }
开发者ID:ArildF,项目名称:masters,代码行数:38,代码来源:xpathnavigator.cs


注:本文中的System.Xml.XPath.XPathNavigator.IsSamePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。