﻿// Decompiled with JetBrains decompiler
// Type: MS.Internal.Xml.XPath.IteratorFilter
// Assembly: System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 50ABAB51-7DC3-4F0A-A797-0D0C2D124D60
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll

using System.Runtime;
using System.Xml.XPath;

namespace MS.Internal.Xml.XPath
{
  internal class IteratorFilter : XPathNodeIterator
  {
    private XPathNodeIterator innerIterator;
    private string name;
    private int position;

    public override XPathNavigator Current
    {
      get
      {
        return this.innerIterator.Current;
      }
    }

    public override int CurrentPosition
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.position;
      }
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    internal IteratorFilter(XPathNodeIterator innerIterator, string name)
    {
      this.innerIterator = innerIterator;
      this.name = name;
    }

    private IteratorFilter(IteratorFilter it)
    {
      this.innerIterator = it.innerIterator.Clone();
      this.name = it.name;
      this.position = it.position;
    }

    public override XPathNodeIterator Clone()
    {
      return (XPathNodeIterator) new IteratorFilter(this);
    }

    public override bool MoveNext()
    {
      while (this.innerIterator.MoveNext())
      {
        if (this.innerIterator.Current.LocalName == this.name)
        {
          ++this.position;
          return true;
        }
      }
      return false;
    }
  }
}
