File: FrameworkFork\Microsoft.Xml\Xml\XPath\Internal\XPathSingletonIterator.cs
Web Access
Project: src\src\dotnet-svcutil\lib\src\dotnet-svcutil-lib.csproj (dotnet-svcutil-lib)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
 
namespace MS.Internal.Xml.XPath
{
    using System;
    using Microsoft.Xml;
    using Microsoft.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);
            _nav = nav;
        }
 
        public XPathSingletonIterator(XPathNavigator nav, bool moved) : this(nav)
        {
            if (moved)
            {
                _position = 1;
            }
        }
 
        public XPathSingletonIterator(XPathSingletonIterator it)
        {
            _nav = it._nav.Clone();
            _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;
        }
    }
}