Ejemplo n.º 1
0
        //
        // IEnumerator interface
        //
        public override bool MoveNext()
        {
            // This variable is used to store the child frame we are currently skipping for.  It's also
            // used as a flag to indicate whether this method should return or continue to the next frame.
            CorFrame childFrame = null;

            bool bMoreToWalk = false;

            while (true)
            {
                // Check to see if the frame we have just given back is a child frame.
                if (m_init)
                {
                    CorFrame prevFrame = this.Current;
                    if ((prevFrame != null) && prevFrame.IsChild)
                    {
                        childFrame = prevFrame;
                    }
                }

                bMoreToWalk = MoveNextWorker();
                if (!bMoreToWalk)
                {
                    // Unless there is a catastrophic failure, we should always find the parent frame for any
                    // child frame.
                    Debug.Assert(childFrame == null);
                    break;
                }

                if (childFrame != null)
                {
                    // We are currently skipping frames due to a child frame.

                    // Check whether the current frame is the parent frame.
                    CorFrame currentFrame = this.Current;
                    if ((currentFrame != null) && childFrame.IsMatchingParentFrame(currentFrame))
                    {
                        // We have reached the parent frame.  We should skip the parent frame as well, so clear
                        // childFrame and unwind to the caller of the parent frame.  We will break out of the
                        // loop on the next iteration.
                        childFrame = null;
                    }
                    continue;
                }
                break;
            }
            return(bMoreToWalk);
        }