Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        protected override void Clear()
        {
            lock (_lock) {
                ChildProviderTable.Clear();
                _siteMapNode       = null;
                _childProviderList = null;

                base.Clear();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        protected virtual void RemoveProvider(string providerName)
        {
            if (providerName == null)
            {
                throw new ArgumentNullException("providerName");
            }

            lock (_lock) {
                SiteMapProvider provider = GetProviderFromName(providerName);
                SiteMapNode     rootNode = (SiteMapNode)ChildProviderTable[provider];

                if (rootNode == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.XmlSiteMapProvider_cannot_find_provider, provider.Name, this.Name));
                }

                provider.ParentProvider = null;
                ChildProviderTable.Remove(provider);
                _childProviderList = null;

                base.RemoveNode(rootNode);
            }
        }