XPathSingletonIterator.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / XPath / Internal / XPathSingletonIterator.cs / 1 / XPathSingletonIterator.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
//-----------------------------------------------------------------------------
 
namespace MS.Internal.Xml.XPath { 
    using System;
    using System.Xml; 
    using System.Xml.XPath;
    using System.Diagnostics;
    using System.Globalization;
 
    internal class XPathSingletonIterator: ResetableIterator {
        private XPathNavigator nav; 
        private int position; 

        public XPathSingletonIterator(XPathNavigator nav) { 
            Debug.Assert(nav != null);
            this.nav = nav;
        }
 
        public XPathSingletonIterator(XPathNavigator nav, bool moved) : this(nav) {
            if (moved) { 
                position = 1; 
            }
        } 

        public XPathSingletonIterator(XPathSingletonIterator it) {
            this.nav      = it.nav.Clone();
            this.position = it.position; 
        }
 
        public override XPathNodeIterator Clone() { 
            return new XPathSingletonIterator(this);
        } 

        public override XPathNavigator Current {
            get { return nav; }
        } 

        public override int CurrentPosition { 
            get { return position; } 
        }
 
        public override int Count {
            get { return 1; }
        }
 
        public override bool MoveNext() {
            if(position == 0) { 
                position = 1; 
                return true;
            } 
            return false;
        }

        public override void Reset() { 
            position = 0;
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK