Beispiel #1
0
        private WebSiteNodeCollection GetNodes()
        {
            WebSiteNode currentNode        = null;
            int         startingNodeOffset = this.StartingNodeOffset;

            if (!string.IsNullOrEmpty(this.StartingNodeUrl) && this.StartFromCurrentNode)
            {
                //throw new InvalidOperationException(SR.GetString("SiteMapDataSource_StartingNodeUrlAndStartFromcurrentNode_Defined"));
            }
            if (this.StartFromCurrentNode)
            {
                currentNode = this.Provider.CurrentNode;
            }
            else if (!string.IsNullOrEmpty(this.StartingNodeUrl))
            {
                currentNode = this.Provider.FindWebSiteNode(this.MakeUrlAbsolute(this.StartingNodeUrl));
                if (currentNode == null)
                {
                    //throw new ArgumentException(SR.GetString("SiteMapPath_CannotFindUrl", new object[] { this.StartingNodeUrl }));
                }
            }
            else
            {
                currentNode = this.Provider.RootNode;
            }
            if (currentNode == null)
            {
                return(null);
            }
            if (startingNodeOffset <= 0)
            {
                if (startingNodeOffset != 0)
                {
                    this.Provider.HintNeighborhoodNodes(currentNode, Math.Abs(startingNodeOffset), 0);
                    WebSiteNode parentNode = currentNode.ParentNode;
                    while ((startingNodeOffset < 0) && (parentNode != null))
                    {
                        currentNode = currentNode.ParentNode;
                        parentNode  = currentNode.ParentNode;
                        startingNodeOffset++;
                    }
                }
                return(this.GetNodes(currentNode));
            }
            WebSiteNode currentNodeAndHintAncestorNodes = this.Provider.GetCurrentNodeAndHintAncestorNodes(-1);

            if (((currentNodeAndHintAncestorNodes == null) || !currentNodeAndHintAncestorNodes.IsDescendantOf(currentNode)) || currentNodeAndHintAncestorNodes.Equals(currentNode))
            {
                return(null);
            }
            WebSiteNode node4 = currentNodeAndHintAncestorNodes;

            for (int i = 0; i < startingNodeOffset; i++)
            {
                node4 = node4.ParentNode;
                if ((node4 == null) || node4.Equals(currentNode))
                {
                    return(this.GetNodes(currentNodeAndHintAncestorNodes));
                }
            }
            WebSiteNode node5 = currentNodeAndHintAncestorNodes;

            while ((node4 != null) && !node4.Equals(currentNode))
            {
                node5 = node5.ParentNode;
                node4 = node4.ParentNode;
            }
            return(this.GetNodes(node5));
        }