BuildSiteMap() public method

public BuildSiteMap ( ) : System.Web.SiteMapNode
return System.Web.SiteMapNode
Example #1
0
        private SiteMapNode GetNodeFromProvider(string providerName)
        {
            SiteMapProvider providerFromName = this.GetProviderFromName(providerName);
            SiteMapNode     rootNodeCore     = null;

            if (providerFromName is XmlSiteMapProvider)
            {
                XmlSiteMapProvider provider2 = (XmlSiteMapProvider)providerFromName;
                StringCollection   strings   = new StringCollection();
                if (this._parentSiteMapFileCollection != null)
                {
                    foreach (string str in this._parentSiteMapFileCollection)
                    {
                        strings.Add(str);
                    }
                }
                provider2.BuildSiteMap();
                strings.Add(this._normalizedVirtualPath.VirtualPathString);
                if (strings.Contains(VirtualPath.GetVirtualPathString(provider2._normalizedVirtualPath)))
                {
                    throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_FileName_already_in_use", new object[] { provider2._virtualPath }));
                }
                provider2._parentSiteMapFileCollection = strings;
            }
            rootNodeCore = providerFromName.GetRootNodeCore();
            if (rootNodeCore == null)
            {
                throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_GetRootNodeCore", new object[] { providerFromName.Name }));
            }
            this.ChildProviderTable.Add(providerFromName, rootNodeCore);
            this._childProviderList         = null;
            providerFromName.ParentProvider = this;
            return(rootNodeCore);
        }
Example #2
0
        private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile)
        {
            SiteMapNode node = null;

            // For external sitemap files, its secuity setting is inherited from parent provider
            bool secuityTrimmingEnabled = SecurityTrimmingEnabled;

            HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, _securityTrimmingEnabledAttrName, ref secuityTrimmingEnabled);

            // No other attributes or non-comment nodes are allowed on a siteMapFile node
            HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
            HandlerBase.CheckForNonCommentChildNodes(xmlNode);

            XmlSiteMapProvider childProvider = new XmlSiteMapProvider();

            // siteMapFile was relative to the sitemap file where this xmlnode is defined, make it an application path.
            siteMapFile = _normalizedVirtualPath.Parent.Combine(siteMapFile);

            childProvider.ParentProvider = this;
            childProvider.Initialize(siteMapFile, secuityTrimmingEnabled);
            childProvider.BuildSiteMap();

            node = childProvider._siteMapNode;

            ChildProviderTable.Add(childProvider, node);
            _childProviderList = null;

            return(node);
        }
Example #3
0
        private SiteMapNode GetNodeFromProvider(string providerName)
        {
            SiteMapProvider provider = GetProviderFromName(providerName);
            SiteMapNode     node     = null;

            // Check infinite recursive sitemap files
            if (provider is XmlSiteMapProvider)
            {
                XmlSiteMapProvider xmlProvider = (XmlSiteMapProvider)provider;

                StringCollection parentSiteMapFileCollection = new StringCollection();
                if (_parentSiteMapFileCollection != null)
                {
                    foreach (string filename in _parentSiteMapFileCollection)
                    {
                        parentSiteMapFileCollection.Add(filename);
                    }
                }

                // Make sure the provider is initialized before adding to the collection.
                xmlProvider.BuildSiteMap();

                parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString);
                if (parentSiteMapFileCollection.Contains(VirtualPath.GetVirtualPathString(xmlProvider._normalizedVirtualPath)))
                {
                    throw new InvalidOperationException(SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, xmlProvider._virtualPath));
                }

                xmlProvider._parentSiteMapFileCollection = parentSiteMapFileCollection;
            }

            node = provider.GetRootNodeCore();
            if (node == null)
            {
                throw new InvalidOperationException(
                          SR.GetString(SR.XmlSiteMapProvider_invalid_GetRootNodeCore, ((ProviderBase)provider).Name));
            }

            ChildProviderTable.Add(provider, node);
            _childProviderList = null;

            provider.ParentProvider = this;

            return(node);
        }
Example #4
0
        private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile)
        {
            SiteMapNode node = null;
            bool        securityTrimmingEnabled = base.SecurityTrimmingEnabled;

            System.Web.Configuration.HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, "securityTrimmingEnabled", ref securityTrimmingEnabled);
            System.Web.Configuration.HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
            System.Web.Configuration.HandlerBase.CheckForNonCommentChildNodes(xmlNode);
            XmlSiteMapProvider key = new XmlSiteMapProvider();

            siteMapFile        = this._normalizedVirtualPath.Parent.Combine(siteMapFile);
            key.ParentProvider = this;
            key.Initialize(siteMapFile, securityTrimmingEnabled);
            key.BuildSiteMap();
            node = key._siteMapNode;
            this.ChildProviderTable.Add(key, node);
            this._childProviderList = null;
            return(node);
        }
Example #5
0
        public static SiteMapDataSource GetSiteMapDataSource(string role)
        {
            string url = String.Empty;

            if (role.Equals("Admin"))

                url = "~/Admin/AdminHomePage.aspx";

            else if (role.Equals("User"))

                url = "~/User/UserHomePage.aspx";

            XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();

            System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);

            myCollection.Add("siteMapFile", "Web.sitemap");

            xmlSiteMap.Initialize("provider", myCollection);

            xmlSiteMap.BuildSiteMap();

            SiteMapDataSource siteMap = new SiteMapDataSource();

            siteMap.StartingNodeUrl = url;

            /* This will not show the starting node and hence giving it

            * the horizontal cool look :)

            * */

            siteMap.ShowStartingNode = false;

            return siteMap;
        }
Example #6
0
        private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile) {

            SiteMapNode node = null;

            // For external sitemap files, its secuity setting is inherited from parent provider
            bool secuityTrimmingEnabled = SecurityTrimmingEnabled;
            HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, _securityTrimmingEnabledAttrName, ref secuityTrimmingEnabled);

            // No other attributes or non-comment nodes are allowed on a siteMapFile node
            HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
            HandlerBase.CheckForNonCommentChildNodes(xmlNode);

            XmlSiteMapProvider childProvider = new XmlSiteMapProvider();

            // siteMapFile was relative to the sitemap file where this xmlnode is defined, make it an application path.
            siteMapFile = _normalizedVirtualPath.Parent.Combine(siteMapFile);

            childProvider.ParentProvider = this;
            childProvider.Initialize(siteMapFile, secuityTrimmingEnabled);
            childProvider.BuildSiteMap();

            node = childProvider._siteMapNode;

            ChildProviderTable.Add(childProvider, node);
            _childProviderList = null;

            return node;
        }
 private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile)
 {
     SiteMapNode node = null;
     bool securityTrimmingEnabled = base.SecurityTrimmingEnabled;
     System.Web.Configuration.HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, "securityTrimmingEnabled", ref securityTrimmingEnabled);
     System.Web.Configuration.HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
     System.Web.Configuration.HandlerBase.CheckForNonCommentChildNodes(xmlNode);
     XmlSiteMapProvider key = new XmlSiteMapProvider();
     siteMapFile = this._normalizedVirtualPath.Parent.Combine(siteMapFile);
     key.ParentProvider = this;
     key.Initialize(siteMapFile, securityTrimmingEnabled);
     key.BuildSiteMap();
     node = key._siteMapNode;
     this.ChildProviderTable.Add(key, node);
     this._childProviderList = null;
     return node;
 }