System.Xml.XPath.XPathNodeIterator.GetEnumerator C# (CSharp) Méthode

GetEnumerator() public méthode

public GetEnumerator ( ) : IEnumerator
Résultat IEnumerator
        public virtual IEnumerator GetEnumerator() {
            return new Enumerator(this);
        }

Usage Example

        private IEnumerable <T> EvaluateIterator <T>(XPathNodeIterator result)
        {
            IEnumerator enumerator = result.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XPathNavigator current          = (XPathNavigator)enumerator.Current;
                object         underlyingObject = current.UnderlyingObject;
                if (!(underlyingObject is T))
                {
                    throw new InvalidOperationException(System.Xml.Linq.Res.GetString("InvalidOperation_UnexpectedEvaluation", new object[] { underlyingObject.GetType() }));
                }
                yield return((T)underlyingObject);

                XText next = underlyingObject as XText;
                if ((next != null) && (next.parent != null))
                {
                    while (next != next.parent.content)
                    {
                        next = next.next as XText;
                        if (next != null)
                        {
                            yield return((T)next);
                        }
                    }
                }
            }
        }