public void Reset()
 {
     this.CheckDisposed();
     this.CheckChanged();
     this.endReached  = false;
     this.enumerator  = null;
     this.currentMode = PrincipalCollectionEnumerator.CurrentEnumeratorMode.None;
 }
        public bool MoveNext()
        {
            bool flag;

            this.CheckDisposed();
            this.CheckChanged();
            if (!this.endReached)
            {
                lock (this.resultSet)
                {
                    if (this.currentMode == PrincipalCollectionEnumerator.CurrentEnumeratorMode.None)
                    {
                        this.resultSet.Reset();
                        if (this.memberCollection.Cleared || this.memberCollection.ClearCompleted)
                        {
                            this.currentMode = PrincipalCollectionEnumerator.CurrentEnumeratorMode.InsertedValuesCompleted;
                            this.enumerator  = this.insertedValuesCompleted.GetEnumerator();
                        }
                        else
                        {
                            this.currentMode = PrincipalCollectionEnumerator.CurrentEnumeratorMode.ResultSet;
                            this.enumerator  = null;
                        }
                    }
                    if (this.currentMode == PrincipalCollectionEnumerator.CurrentEnumeratorMode.ResultSet)
                    {
                        bool flag1 = false;
                        do
                        {
                            bool flag2 = this.resultSet.MoveNext();
                            if (!flag2)
                            {
                                this.currentMode = PrincipalCollectionEnumerator.CurrentEnumeratorMode.InsertedValuesCompleted;
                                this.enumerator  = this.insertedValuesCompleted.GetEnumerator();
                                flag1            = false;
                            }
                            else
                            {
                                Principal currentAsPrincipal = (Principal)this.resultSet.CurrentAsPrincipal;
                                if (this.removedValuesCompleted.Contains(currentAsPrincipal) || this.removedValuesPending.Contains(currentAsPrincipal))
                                {
                                    flag1 = true;
                                }
                                else
                                {
                                    if (this.insertedValuesCompleted.Contains(currentAsPrincipal) || this.insertedValuesPending.Contains(currentAsPrincipal))
                                    {
                                        flag1 = true;
                                    }
                                    else
                                    {
                                        flag1        = false;
                                        this.current = currentAsPrincipal;
                                        flag         = true;
                                        return(flag);
                                    }
                                }
                            }
                        }while (flag1);
                    }
                    if (this.currentMode == PrincipalCollectionEnumerator.CurrentEnumeratorMode.InsertedValuesCompleted)
                    {
                        bool flag3 = this.enumerator.MoveNext();
                        if (!flag3)
                        {
                            this.currentMode = PrincipalCollectionEnumerator.CurrentEnumeratorMode.InsertedValuesPending;
                            this.enumerator  = this.insertedValuesPending.GetEnumerator();
                        }
                        else
                        {
                            this.current = this.enumerator.Current;
                            flag         = true;
                            return(flag);
                        }
                    }
                    if (this.currentMode != PrincipalCollectionEnumerator.CurrentEnumeratorMode.InsertedValuesPending)
                    {
                        return(false);
                    }
                    else
                    {
                        bool flag4 = this.enumerator.MoveNext();
                        if (!flag4)
                        {
                            this.endReached = true;
                            flag            = false;
                        }
                        else
                        {
                            this.current = this.enumerator.Current;
                            flag         = true;
                        }
                    }
                }
                return(flag);
            }
            else
            {
                return(false);
            }
        }