Exemplo n.º 1
0
        ///<summary>
        ///Returns an enumerator that iterates through the collection.
        ///</summary>
        ///
        ///<returns>
        ///A <see cref="T:System.Collections.Generic.IEnumerator`1"></see> that can be used to iterate through the collection.
        ///</returns>
        ///<filterpriority>1</filterpriority>
        public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
        {
            int currentVersion = _version;

            for (IEnumerator <KeyValuePair <TKey, TValue> > enumerator = _persistHandler.GetEnumerator(); enumerator.MoveNext();)
            {
                if (currentVersion != _version)
                {
                    throw new InvalidOperationException("Collection modified during enumeration");
                }
                yield return(enumerator.Current);
            }
        }