Пример #1
0
        public LevelMetadata FindFirstLink()
        {
            LevelMetadata firstLink    = this;
            LevelMetadata previousLink = this;

            //loop until the previous link is null
            while (previousLink != null)
            {
                firstLink    = previousLink;
                previousLink = previousLink.PreviousLink();
            }

            return(firstLink);
        }
Пример #2
0
        public bool FindBrokenLink(ref LevelMetadata brokenLevel, ref bool forwardLink)
        {
            //initialize the out params - assume no broken link
            brokenLevel = null;
            forwardLink = false;

            //First, walk backwards to the first link
            LevelMetadata currentLink  = this;
            LevelMetadata previousLink = null;
            LevelMetadata nextLink     = null;

            while (currentLink.LinkedFromLevel != null)
            {
                //check to make sure the xml exists
                previousLink = currentLink.PreviousLink();

                if (null == previousLink)
                {
                    brokenLevel = currentLink;
                    forwardLink = false; //broke walking backwards

                    return(true);
                }
                currentLink = previousLink;
            }

            //first link now points to the beginning, walk forward to the end, ensuring we
            while (currentLink.LinkedToLevel != null)
            {
                //check to make sure the xml exists
                nextLink = currentLink.NextLink();

                if (null == nextLink)
                {
                    brokenLevel = currentLink;
                    forwardLink = false; //broke walking backwards

                    return(true);
                }
                currentLink = nextLink;
            }

            //if we made it this far, all of the links worked out
            return(false);
        }