Initialize() 공개 메소드

public Initialize ( string name, NameValueCollection attributes ) : void
name string
attributes NameValueCollection
리턴 void
예제 #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);
        }
예제 #2
0
        private static SiteMapProvider CreateProvider()
        {
            SiteMapProvider xmlProvider = new XmlSiteMapProvider();

            xmlProvider.Initialize("internal", new NameValueCollection { { "securityTrimmingEnabled", "true" }, { "siteMapFile", "Web.sitemap" } });

            return xmlProvider;
        }
예제 #3
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);
        }
예제 #4
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;
        }
 public override SiteMapNode BuildSiteMap()
 {
     if (rootNode == null)
         lock (this)
         {
             if (rootNode == null)
             {
                 if (log.IsDebugEnabled)
                     log.Debug("Dynamically filling site map with atome site maps...");
                 rootNode = BuildRootNode();
                 foreach (string siteMap in GetSiteMapPaths())
                 {
                     var provider = new XmlSiteMapProvider();
                     var attributes = new NameValueCollection();
                     attributes.Add("siteMapFile", siteMap);
                     provider.Initialize("test", attributes);
                     AddNode(provider.RootNode, rootNode);
                     if (log.IsDebugEnabled)
                         log.Debug("site map " + siteMap + " added.");
                 }
             }
         }
     return rootNode;
 }
예제 #6
0
        void BuildSiteMapRecursive(XmlNode xmlNode, SiteMapNode parent)
        {
            if (xmlNode.Name != "siteMapNode")
            {
                throw new ConfigurationException("incorrect element name", xmlNode);
            }

            string attrValue = GetNonEmptyOptionalAttribute(xmlNode, "provider");

            if (attrValue != null)
            {
                SiteMapProvider provider = SiteMap.Providers [attrValue];
                if (provider == null)
                {
                    throw new ProviderException("Provider with name [" + attrValue + "] was not found.");
                }

                provider.ParentProvider = this;
                SiteMapNode providerRoot = provider.GetRootNodeCore();

                if (parent == null)
                {
                    root = providerRoot;
                }
                else
                {
                    AddNodeNoCheck(providerRoot, parent);
                }
                return;
            }

            attrValue = GetNonEmptyOptionalAttribute(xmlNode, "siteMapFile");
            if (attrValue != null)
            {
                var nvc = new NameValueCollection();
                nvc.Add("siteMapFile", attrValue);

                string description = GetOptionalAttribute(xmlNode, "description");
                if (!String.IsNullOrEmpty(description))
                {
                    nvc.Add("description", description);
                }

                string name     = MapUrl(attrValue);
                var    provider = new XmlSiteMapProvider();
                provider.Initialize(name, nvc);

                SiteMapNode providerRoot = provider.GetRootNodeCore();
                if (parent == null)
                {
                    root = providerRoot;
                }
                else
                {
                    AddNodeNoCheck(providerRoot, parent);
                }
                return;
            }

            SiteMapNode curNode = ConvertToSiteMapNode(xmlNode);

            if (parent == null)
            {
                root = curNode;
            }
            else
            {
                AddNodeNoCheck(curNode, parent);
            }

            XmlNodeList childNodes = xmlNode.ChildNodes;

            if (childNodes == null || childNodes.Count < 1)
            {
                return;
            }

            foreach (XmlNode child in childNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                BuildSiteMapRecursive(child, curNode);
            }
        }
		void BuildSiteMapRecursive (XmlNode xmlNode, SiteMapNode parent)
		{
			if (xmlNode.Name != "siteMapNode")
				throw new ConfigurationException ("incorrect element name", xmlNode);
			
			string attrValue = GetNonEmptyOptionalAttribute (xmlNode, "provider");
			if (attrValue != null) {
				SiteMapProvider provider = SiteMap.Providers [attrValue];
				if (provider == null)
					throw new ProviderException ("Provider with name [" + attrValue + "] was not found.");

				provider.ParentProvider = this;
				SiteMapNode providerRoot = provider.GetRootNodeCore();

				if (parent == null)
					root = providerRoot;
				else
					AddNodeNoCheck (providerRoot, parent);
				return;
			}

			attrValue = GetNonEmptyOptionalAttribute (xmlNode, "siteMapFile");
			if (attrValue != null) {
				var nvc = new NameValueCollection ();
				nvc.Add ("siteMapFile", attrValue);

				string description = GetOptionalAttribute (xmlNode, "description");
				if (!String.IsNullOrEmpty (description))
					nvc.Add ("description", description);

				string name = MapUrl (attrValue);				
				var provider = new XmlSiteMapProvider ();
				provider.Initialize (name, nvc);
				
				SiteMapNode providerRoot = provider.GetRootNodeCore ();
				if (parent == null)
					root = providerRoot;
				else
					AddNodeNoCheck (providerRoot, parent);
				return;
			}

			SiteMapNode curNode = ConvertToSiteMapNode (xmlNode);
			if (parent == null)
				root = curNode;
			else
				AddNodeNoCheck (curNode, parent);
			
			XmlNodeList childNodes = xmlNode.ChildNodes;
			if (childNodes == null || childNodes.Count < 1)
				return;
			
			foreach (XmlNode child in childNodes) {
				if (child.NodeType != XmlNodeType.Element)
					continue;

				BuildSiteMapRecursive (child, curNode);
			}
		}
예제 #8
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;
 }