当前位置: 首页>>代码示例>>C#>>正文


C# Web.SiteMapNode类代码示例

本文整理汇总了C#中System.Web.SiteMapNode的典型用法代码示例。如果您正苦于以下问题:C# SiteMapNode类的具体用法?C# SiteMapNode怎么用?C# SiteMapNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SiteMapNode类属于System.Web命名空间,在下文中一共展示了SiteMapNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildSiteMap

        public override SiteMapNode BuildSiteMap()
        {
            lock (this)
            {

                if (!IsInitialized)
                {
                    throw new Exception("BuildSiteMap called incorrectly.");
                }

                if (null == rootNode)
                {
                    // Start with a clean slate
                    Clear();

                    // Select the root node of the site map from Microsoft Access.

                    DataTable table = GetMenuDataSource();

                    if (table.Rows.Count > 0)
                    {
                        rootNode = new SiteMapNode(this, "0");
                        // ����һ�зdz���Ҫ�������ܹ���ȷ��ʾ�˵�
                         AddNode(rootNode,null);
                        BuildSonMenuNode(table, rootNode);
                    }
                    else
                    {
                        return null;
                    }
                }

                return rootNode;
            }
        }
开发者ID:ViniciusConsultor,项目名称:noname-netshop,代码行数:35,代码来源:SqlSiteMapProvider.cs

示例2: CreateNodeWithOutChildren

        //dynamic node creation
        public static Node CreateNodeWithOutChildren(SiteMapNode siteMapNode)
        {
            Node treeNode;

            if (siteMapNode.ChildNodes != null && siteMapNode.ChildNodes.Count > 0)
            {
                treeNode = new Node();
            }
            else
            {
                treeNode = new Node();
                treeNode.Leaf = true;
            }

            if (!string.IsNullOrEmpty(siteMapNode.Url))
            {
                treeNode.Href = siteMapNode.Url.StartsWith("~/") ? siteMapNode.Url.Replace("~/", "http://examples.ext.net/") : ("http://examples.ext.net" + siteMapNode.Url);
            }

            treeNode.NodeID = siteMapNode.Key;
            treeNode.Text = siteMapNode.Title;
            treeNode.Qtip = siteMapNode.Description;

            return treeNode;
        }
开发者ID:extnet,项目名称:Ext.NET.Examples.MVC,代码行数:26,代码来源:SiteMapModel.cs

示例3: CreateNode

        //static node creation with children
        public static Node CreateNode(SiteMapNode siteMapNode)
        {
            Node treeNode = new Node();

            if (!string.IsNullOrEmpty(siteMapNode.Url))
            {

                treeNode.CustomAttributes.Add(new ConfigItem("url", siteMapNode.Url.StartsWith("~/") ? siteMapNode.Url.Replace("~/", "http://examples.ext.net/") : ("http://examples.ext.net" + siteMapNode.Url)));
                treeNode.Href = "#";
            }

            treeNode.NodeID = siteMapNode.Key;
            treeNode.CustomAttributes.Add(new ConfigItem("hash", siteMapNode.Key.GetHashCode().ToString()));
            treeNode.Text = siteMapNode.Title;
            treeNode.Qtip = siteMapNode.Description;

            SiteMapNodeCollection children = siteMapNode.ChildNodes;

            if (children != null && children.Count > 0)
            {
                foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                {
                    treeNode.Children.Add(SiteMapModel.CreateNode(mapNode));
                }
            }
            else
            {
                treeNode.Leaf = true;
            }

            return treeNode;
        }
开发者ID:extnet,项目名称:Ext.NET.Examples.MVC,代码行数:33,代码来源:SiteMapModel.cs

示例4: BuildNodeTree

        private SiteMapNode BuildNodeTree()
        {
            Clear();

            SiteMapNode root = new SiteMapNode(this, "Root", "/", null);
            AddNode(root);

            SPWeb currentsiteRootweb = NCTopMenuHelper.GetCurrentRootWeb();

            SiteMapNode node;

            List<SPWeb> webs = new List<SPWeb>();

            foreach (SPWeb web in currentsiteRootweb.Webs)
            {
                webs.Add(web);
            }

            webs.Sort(new Comparison<SPWeb>(SortWebs));

            foreach (SPWeb web in webs)
            {
                string serverRelativeUrl = "";

                if (web.Webs.Count == 0)
                    serverRelativeUrl = web.ServerRelativeUrl;
                else
                    serverRelativeUrl = getSubsiteUrl(web);

                node = new SiteMapNode(this, web.ID.ToString(), serverRelativeUrl, web.Title);
                AddNode(node, root);
            }

            return root;
        }
开发者ID:MohitVash,项目名称:TestProject,代码行数:35,代码来源:NCNewssiteTopNavigationProviderLevel1.cs

示例5: IsAccessibleToUser

        //public List<UrlUser> lu = new List<UrlUser>();
        public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
        {
            if (node.Description.ToLower() == "invisible") return false;

            if (node.Key.ToLower() == "/default.aspx") return true;
            if (UserHelper.IsSysAdmin || string.IsNullOrEmpty(node.Url)) return true;

            List<UrlUser> lu = (List<UrlUser>)HttpContext.Current.Session["IsAccessibleToUser"];
            if (lu == null)
            {
                lu = new List<UrlUser>();
                bool res = !Security.IsDeniedURL(node.Url, UserHelper.DealerCode);
                lu.Add(new UrlUser { res = res, Url = node.Url, DealerCode = UserHelper.DealerCode });
                HttpContext.Current.Session["IsAccessibleToUser"] = lu;
                return res;
            }
            else
            {
                var q = lu.Where(l => l.Url == node.Url && l.DealerCode == UserHelper.DealerCode);
                UrlUser uu = new UrlUser();
                if (q.Count() > 0)
                    uu = q.First();
                else
                    uu = null;
                if (uu != null)
                    return uu.res;
                else
                {
                    bool res = !Security.IsDeniedURL(node.Url, UserHelper.DealerCode);
                    lu.Add(new UrlUser { res = res, Url = node.Url, DealerCode = UserHelper.DealerCode });
                    HttpContext.Current.Session["IsAccessibleToUser"] = lu;
                    return res;
                }
            }
        }
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:36,代码来源:VDMSSiteMapProvider.cs

示例6: AddNode

 protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     if (parentNode == null)
     {
         throw new ArgumentNullException("parentNode");
     }
     SiteMapProvider provider = node.Provider;
     SiteMapProvider provider2 = parentNode.Provider;
     if (provider != this)
     {
         throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { node.ToString() }), "node");
     }
     if (provider2 != this)
     {
         throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
     }
     lock (base._lock)
     {
         this.RemoveNode(node);
         this.AddNodeInternal(node, parentNode, null);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlSiteMapProvider.cs

示例7: GetChildNodes

        /// <exclude />
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            Verify.ArgumentNotNull(node, "node");

            var pageSiteMapNode = (CmsPageSiteMapNode)node;

            var context = HttpContext.Current;

            List<SiteMapNode> childNodes;
            using (new DataScope(pageSiteMapNode.Culture))
            {
                childNodes = PageManager.GetChildrenIDs(pageSiteMapNode.Page.Id)
                    .Select(PageManager.GetPageById)
                    .Where(p => p != null)
                    .Select(p => new CmsPageSiteMapNode(this, p))
                    .OfType<SiteMapNode>()
                    .ToList();
            }

            if (!childNodes.Any())
            {
                return EmptyCollection;
            }

            if (SecurityTrimmingEnabled)
            {
                childNodes = childNodes.Where(child => child.IsAccessibleToUser(context)).ToList();
            }

            return new SiteMapNodeCollection(childNodes.ToArray());
        }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:32,代码来源:CmsPageSiteMapProvider.cs

示例8: BuildDesignTimeSiteMapInternal

 private SiteMapNode BuildDesignTimeSiteMapInternal()
 {
     if (this._rootNode == null)
     {
         this._rootNode = new SiteMapNode(this, _rootNodeText + " url", _rootNodeText + " url", _rootNodeText, _rootNodeText);
         this._currentNode = new SiteMapNode(this, _currentNodeText + " url", _currentNodeText + " url", _currentNodeText, _currentNodeText);
         SiteMapNode node = this.CreateNewSiteMapNode(_parentNodeText);
         SiteMapNode node2 = this.CreateNewSiteMapNode(_siblingNodeText1);
         SiteMapNode node3 = this.CreateNewSiteMapNode(_siblingNodeText2);
         SiteMapNode node4 = this.CreateNewSiteMapNode(_siblingNodeText3);
         SiteMapNode node5 = this.CreateNewSiteMapNode(_childNodeText1);
         SiteMapNode node6 = this.CreateNewSiteMapNode(_childNodeText2);
         SiteMapNode node7 = this.CreateNewSiteMapNode(_childNodeText3);
         this.AddNode(this._rootNode);
         this.AddNode(node, this._rootNode);
         this.AddNode(node2, node);
         this.AddNode(this._currentNode, node);
         this.AddNode(node3, node);
         this.AddNode(node4, node);
         this.AddNode(node5, this._currentNode);
         this.AddNode(node6, this._currentNode);
         this.AddNode(node7, this._currentNode);
     }
     return this._rootNode;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:DesignTimeSiteMapProviderBase.cs

示例9: IsAccessibleToUser

        /// <summary>
        /// Determines whether node is accessible to user.
        /// </summary>
        /// <param name="controllerTypeResolver">The controller type resolver.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// 	<c>true</c> if accessible to user; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node)
        {
            // Is security trimming enabled?
            if (!provider.SecurityTrimmingEnabled)
            {
                return true;
            }

            // Use child modules
            bool result = true;
            foreach (var module in ChildModules)
            {
                try
                {
                    result &= module.IsAccessibleToUser(controllerTypeResolver, provider, context, node);
                }
                catch (AclModuleNotSupportedException)
                {
                    result &= true; // Convention throughout the provider: if the IAclModule can not authenticate a user, true is returned.
                }
                if (result == false)
                {
                    return false;
                }
            }

            // Return
            return result;
        }
开发者ID:ritacc,项目名称:RitaccTest,代码行数:39,代码来源:DefaultAclModule.cs

示例10: BuildSiteMap

        public override SiteMapNode BuildSiteMap()
        {
            lock(this) {
                Clear();

                var dalc = WebManager.GetService<IDalc>(DalcName);
                var ds = new DataSet();
                dalc.Load(ds, new Query(SourceName));
                rootNode = new SiteMapNode(this, "root", RootUrl, RootTitle);
                var idToNode = new Dictionary<string, SiteMapNode>();

                // build nodes
                foreach (DataRow r in ds.Tables[SourceName].Rows) {
                    var node = CreateNode( r );
                    idToNode[node.Key] = node;
                }
                // set hierarchy relations
                foreach (DataRow r in ds.Tables[SourceName].Rows) {
                    var node = idToNode[ Convert.ToString( r[IdField] ) ];
                    var parentKey = Convert.ToString(r[FkField]);
                    if (r[FkField] != DBNull.Value && idToNode.ContainsKey(parentKey))
                        AddNode(node, idToNode[parentKey]);
                    else
                        AddNode(node, rootNode);
                }

            }
            return rootNode;
        }
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:29,代码来源:DalcSiteMapProvider.cs

示例11: BuildMenuRecursive

        private void BuildMenuRecursive(StringBuilder sb, SiteMapNode node)
        {
            string imgUrl = node["IconUrl"];
            if (!String.IsNullOrEmpty(imgUrl) && imgUrl.StartsWith("~/"))
            {
                imgUrl = imgUrl.Substring(2, imgUrl.Length - 2);
                imgUrl = CommonHelper.GetStoreLocation() + imgUrl;
            }

            string title = HttpUtility.HtmlEncode(!String.IsNullOrEmpty(node["nopResourceTitle"]) ? GetLocaleResourceString(node["nopResourceTitle"]) : node.Title);
            string descr = HttpUtility.HtmlEncode(!String.IsNullOrEmpty(node["nopResourceDescription"]) ? GetLocaleResourceString(node["nopResourceDescription"]) : node.Description);

            sb.Append("<li>");
            sb.AppendFormat("<a href=\"{0}\" title=\"{2}\">{3}{1}</a>", (String.IsNullOrEmpty(node.Url) ? "#" : node.Url), title, descr, (!String.IsNullOrEmpty(imgUrl) ? String.Format("<img src=\"{0}\" alt=\"{1}\" /> ", imgUrl, title) : String.Empty));
            if(node.HasChildNodes)
            {
                sb.Append("<ul>");
                foreach(SiteMapNode childNode in node.ChildNodes)
                {
                    BuildMenuRecursive(sb, childNode);
                }
                sb.Append("</ul>");
            }
            sb.Append("</li>");
        }
开发者ID:krishnaMoulicgs,项目名称:Sewbie_BugFixing,代码行数:25,代码来源:MenuControl.ascx.cs

示例12: CheckInstructions

 public static void CheckInstructions(SiteMapNode node, TextWriter report)
 {
   try
   {
     if (node.Url.IndexOf(".wma.") >= 0 || node.Url.EndsWith(".aspx")) return;
     lm_scorm root = LMDataReader.Read(node);
     if (root.template == template_Type.unknown)
     {
       //dumpError(node.Url, report, "Unknown template", null, null);
     }
     else if (root.HasInstruction)
     {
       design_time dsgn = GetTemplateDesignTime(root.template);
       if (dsgn != null)
       {
         if (root.PageInfo.ProdInfo == null)
           throw new Exception("Unknown project in web.config");
         if (root.title == null || (!root.extra_title && !dsgn.TitleOK(root)))
           dumpError(node.Url, report, "Title", root.title, dsgn.AllTitles(root.PageInfo.ProdInfo.Lang));
         foreach (techInstr_Type instr in new techInstr_Type[] { root.instr, root.instr2, root.instr3 })
           if (instr != techInstr_Type.no && !dsgn.instrs.ContainsKey(instr))
             dumpError(node.Url, report, "Instr", instr, dsgn.instrs.Keys);
       }
     }
   }
   catch (Exception e)
   {
     dumpError(node.Url, report, "Cannot read page (" + e.Message + ")", null, null);
   }
   if (node.HasChildNodes)
     foreach (SiteMapNode nd in node.ChildNodes)
       CheckInstructions(nd, report);
 }
开发者ID:PavelPZ,项目名称:REW,代码行数:33,代码来源:Manager.cs

示例13: AddNode

		internal protected override void AddNode (SiteMapNode node, SiteMapNode parentNode)
		{
			if (node == null)
				throw new ArgumentNullException ("node");
			
			lock (this) {
				string url = node.Url;
				if (url != null && url.Length > 0) {
					if (UrlUtils.IsRelativeUrl (url))
						url = UrlUtils.Combine (HttpRuntime.AppDomainAppVirtualPath, url);
					else
						url = UrlUtils.ResolveVirtualPathFromAppAbsolute (url);
					
					if (FindSiteMapNode (url) != null)
						throw new InvalidOperationException ();
				
					UrlToNode [url] = node;
				}
				
				if (FindSiteMapNodeFromKey (node.Key) != null)
					throw new InvalidOperationException (string.Format ("A node with key {0} already exists.",node.Key));
				KeyToNode [node.Key] = node;
				
				if (parentNode != null) {
					NodeToParent [node] = parentNode;
					if (NodeToChildren [parentNode] == null)
						NodeToChildren [parentNode] = new SiteMapNodeCollection ();
					
					((SiteMapNodeCollection) NodeToChildren [parentNode]).Add (node);
				}
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:StaticSiteMapProvider.cs

示例14: BuildFullMenuStructure

        private SiteMapNode BuildFullMenuStructure(SPWeb currentWeb)
        {
            Clear();

            SiteMapNode root = null;

            SPWeb webSite = SPContext.Current.Site.RootWeb;
            string relativeUrl = webSite.ServerRelativeUrl.ToString();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite currentsite = new SPSite(webSite.Site.Url);
                SPWeb rootweb = currentsite.OpenWeb(relativeUrl);

                root = new SiteMapNode(this, rootweb.ID.ToString(), rootweb.ServerRelativeUrl, rootweb.Title);

                if (rootweb == currentWeb)
                {
                    SiteMapNode root2 = new SiteMapNode(this, "Root", "/", null);
                    AddNode(root2);

                    string cacheKey = rootweb.ID.ToString();
                    AddMenuToCache(cacheKey, root2);
                }

                foreach (SPWeb web in rootweb.Webs)
                {
                    SiteMapNode node = BuildNodeTree(web);
                    AddNode(node, root);
                }
            });

            return root;
        }
开发者ID:MohitVash,项目名称:TestProject,代码行数:34,代码来源:NCNewssiteTopNavigationProviderLevel2.cs

示例15: BuildSiteMap

		public override SiteMapNode BuildSiteMap ()
		{
			if (root != null)
				return root;
			// Whenever you call AddNode, it tries to find dups, and will call this method
			// Is this a bug in MS??
			if (building)
				return null;
			
			lock (this) {
				try {
					building = true;
					if (root != null)
						return root;
					XmlDocument d = new XmlDocument ();
					d.Load (file);
					
					XmlNode nod = d.DocumentElement ["siteMapNode"];
					if (nod == null)
						throw new HttpException ("Invalid site map file: " + Path.GetFileName (file));
						
					root = BuildSiteMapRecursive (nod);
						
					AddNode (root);
				} finally {
					building = false;
				}
				return root;
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:XmlSiteMapProvider.cs


注:本文中的System.Web.SiteMapNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。