• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISiteMapNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: IsAccessibleToUser

        /// <summary>
        /// Determines whether node is accessible to user.
        /// </summary>
        /// <param name="siteMap">The site map.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        /// 	<c>true</c> if accessible to user; otherwise, <c>false</c>.
        /// </returns>
        public bool IsAccessibleToUser(ISiteMap siteMap, ISiteMapNode node)
        {
            // If we have roles assigned, check them against the roles defined in the sitemap
            if (node.Roles != null && node.Roles.Count > 0)
            {
                var context = mvcContextFactory.CreateHttpContext();

                    // if there is an authenticated user and the role allows anyone authenticated ("*"), show it
                if ((context.User.Identity.IsAuthenticated) && node.Roles.Contains("*"))
                {
                    return true;
                }

                    // if there is no user, but the role allows unauthenticated users ("?"), show it
                if ((!context.User.Identity.IsAuthenticated) && node.Roles.Contains("?"))
                    {
                        return true;
                    }

                    // if the user is in one of the listed roles, show it
                if (node.Roles.OfType<string>().Any(role => context.User.IsInRole(role)))
                    {
                        return true;
                    }

                    // if we got this far, deny showing
                    return false;
            }

            // Everything seems OK...
            return true;
        }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:40,代码来源:XmlRolesAclModule.cs


示例2: GetDynamicNodeCollection

        public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            var categories = _unitOfWork.CategoryRepository.Get().ToList();// categoryBuilder.Build();

            foreach (var category in categories.Where(i=>i.ParentCategory==null))
            {
                var dynamicNode = new DynamicNode();
                dynamicNode.Title = category.Name;
                dynamicNode.Key = category.Id.ToString();
                dynamicNode.RouteValues.Add("id",category.Id);

                var category1 = category;
                foreach (var childCategory in categories.Where(c=>c.ParentCategory==category1))
                {
                    var childDynamicNode = new DynamicNode();
                    childDynamicNode.Title = childCategory.Name;
                    childDynamicNode.ParentKey = category.Id.ToString();
                    childDynamicNode.Key = childCategory.Id.ToString();
                    childDynamicNode.RouteValues.Add("id",childCategory.Id);
/*                    foreach (var productItem in productItems.Where(i=>i.CategoryId==childCategory.Id))
                    {
                        var productDynamicNode = new DynamicNode();
                        productDynamicNode.Title = productItem.Name;
                        productDynamicNode.ParentKey = childCategory.Id;
                        productDynamicNode.Key = productItem.Id;
                        productDynamicNode.RouteValues.Add("id", productItem.Id);

                        yield return productDynamicNode;
                    }*/
                    yield return childDynamicNode;
                }

                yield return dynamicNode;
            }
        }
开发者ID:HaoTan,项目名称:APlusSecurityNZ,代码行数:35,代码来源:ProductsDynamicNodeProvider.cs


示例3: GetDynamicNodeCollection

 public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode nodes)
 {
     var returnValue = new List<DynamicNode>();
     
     // 向BLL層取得選單
     foreach (var item in PermissionService.GetMenu())
     {
         DynamicNode node = new DynamicNode();
         // 選單名稱
         node.Title = item.Name; 
         // 有無父類別,沒有的話則傳空字串
         node.ParentKey = item.ParentID == 0 ? "" : item.ParentID.ToString();
         // 唯一值
         node.Key = item.MenuID.ToString();
         // MVC的View
         node.Action = item.Action;
         // MVC的Controller
         node.Controller = item.Controller;
         // 選單所分配的腳色,逗號分隔
         node.Roles = item.Roles.Split(',').Where(c => !string.IsNullOrEmpty(c)).ToList();
         // 
         node.RouteValues.Add("id", item.MenuID);
         returnValue.Add(node);
     }
     // Return
     return returnValue;
 }
开发者ID:haoas,项目名称:2014.IT.Ironman7,代码行数:27,代码来源:PageDynamicNodeProvider.cs


示例4: AddDescendantNodes

        protected virtual void AddDescendantNodes(
            ISiteMap siteMap,
            ISiteMapNode currentNode,
            IList<ISiteMapNodeToParentRelation> sourceNodes,
            ILookup<string, ISiteMapNodeToParentRelation> sourceNodesByParent,
            HashSet<string> nodesAlreadyAdded)
        {
            if (sourceNodes.Count == 0)
            {
                return;
            }

            var children = sourceNodesByParent[currentNode.Key].OrderBy(x => x.Node.Order).ToArray();
            if (children.Count() == 0)
            {
                return;
            }

            foreach (var child in children)
            {
                if (sourceNodes.Count == 0)
                {
                    return;
                }

                this.AddAndTrackNode(siteMap, child, currentNode, sourceNodes, nodesAlreadyAdded);

                if (sourceNodes.Count == 0)
                {
                    return;
                }

                this.AddDescendantNodes(siteMap, child.Node, sourceNodes, sourceNodesByParent, nodesAlreadyAdded);
            }
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:35,代码来源:SiteMapHierarchyBuilder.cs


示例5: SiteMapNodeUrlKey

        public SiteMapNodeUrlKey(
            ISiteMapNode node,
            IUrlPath urlPath
            )
            : base(urlPath)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            this.node = node;

            // Host name in absolute URL overrides this one.
            this.hostName = node.HostName;

            // Fixes #322 - If using a custom URL resolver, we need to account for the case that
            // the URL will be provided by the resolver instead of specified explicitly.
            if (!string.IsNullOrEmpty(node.UnresolvedUrl))
            {
                this.SetUrlValues(node.UnresolvedUrl);
            }
            else if (!node.UsesDefaultUrlResolver())
            {
                // For a custom URL resolver, if the unresolved URL property
                // is not set use the one returned from the URL resolver.
                // This ensures URLs that are unidentifiable by MVC can still
                // be matched by URL.
                this.SetUrlValues(node.Url);
            }
        }
开发者ID:Relix1990,项目名称:MvcSiteMapProvider,代码行数:29,代码来源:SiteMapNodeUrlKey.cs


示例6: SiteMapNodeModel

        /// <summary>
        /// Initializes a new instance of the <see cref="SiteMapNodeModel"/> class.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="sourceMetadata">The source metadata provided by the HtmlHelper.</param>
        /// <param name="maxDepth">The max depth.</param>
        /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
        /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param>
        public SiteMapNodeModel(ISiteMapNode node, IDictionary<string, object> sourceMetadata, int maxDepth, bool drillDownToCurrent, bool startingNodeInChildLevel, bool visibilityAffectsDescendants)
        {
            if (node == null)
                throw new ArgumentNullException("node");
            if (sourceMetadata == null)
                throw new ArgumentNullException("sourceMetadata");
            if (maxDepth < 0)
                throw new ArgumentOutOfRangeException("maxDepth");

            this.node = node;
            this.maxDepth = maxDepth;
            this.startingNodeInChildLevel = startingNodeInChildLevel;
            this.drillDownToCurrent = drillDownToCurrent;
            this.SourceMetadata = sourceMetadata;

            Key = node.Key;
            Area = node.Area;
            Controller = node.Controller;
            Action = node.Action;
            Title = node.Title;
            Description = node.Description;
            TargetFrame = node.TargetFrame;
            ImageUrl = node.ImageUrl;
            Url = node.Url;
            CanonicalUrl = node.CanonicalUrl;
            MetaRobotsContent = node.GetMetaRobotsContentString();
            IsCurrentNode = (node == node.SiteMap.CurrentNode);
            IsInCurrentPath = node.IsInCurrentPath();
            IsRootNode = (node == node.SiteMap.RootNode);
            IsClickable = node.Clickable;
            VisibilityAffectsDescendants = visibilityAffectsDescendants;
            RouteValues = node.RouteValues;
            Attributes = node.Attributes;
        }
开发者ID:rene15009,项目名称:MvcSiteMapProvider,代码行数:42,代码来源:SiteMapNodeModel.cs


示例7: XmlSiteMapResult

        public XmlSiteMapResult(
            int page,
            ISiteMapNode rootNode,
            IEnumerable<string> siteMapCacheKeys,
            string baseUrl,
            string siteMapUrlTemplate,
            ISiteMapLoader siteMapLoader,
            IUrlPath urlPath,
            ICultureContextFactory cultureContextFactory)
        {
            if (siteMapLoader == null)
                throw new ArgumentNullException("siteMapLoader");
            if (urlPath == null)
                throw new ArgumentNullException("urlPath");
            if (cultureContextFactory == null)
                throw new ArgumentNullException("cultureContextFactory");

            this.Ns = "http://www.sitemaps.org/schemas/sitemap/0.9";
            this.Page = page;
            this.RootNode = rootNode;
            this.SiteMapCacheKeys = siteMapCacheKeys;
            this.BaseUrl = baseUrl;
            this.SiteMapUrlTemplate = siteMapUrlTemplate;
            this.siteMapLoader = siteMapLoader;
            this.urlPath = urlPath;
            this.cultureContextFactory = cultureContextFactory;
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:27,代码来源:XmlSiteMapResult.cs


示例8: Execute

 public void Execute(ISiteMapNode node)
 {
     foreach (var visitor in this.siteMapNodeVisitors)
     {
         visitor.Execute(node);
     }
 }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:7,代码来源:CompositeSiteMapNodeVisitor.cs


示例9: ResolveUrl

 /// <summary>
 /// Resolves the URL.
 /// </summary>
 /// <param name="node">The MVC site map node.</param>
 /// <param name="area">The area.</param>
 /// <param name="controller">The controller.</param>
 /// <param name="action">The action.</param>
 /// <param name="routeValues">The route values.</param>
 /// <returns>The resolved URL.</returns>
 public override string ResolveUrl(ISiteMapNode node, string area, string controller, string action, IDictionary<string, object> routeValues)
 {
     if (!string.IsNullOrEmpty(node.UnresolvedUrl))
     {
         return this.ResolveVirtualPath(node);
     }
     return this.ResolveRouteUrl(node, area, controller, action, routeValues);
 }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:17,代码来源:SiteMapNodeUrlResolver.cs


示例10: CreateHttpContext

        protected virtual HttpContextBase CreateHttpContext(ISiteMapNode node, TextWriter writer)
        {
            var currentHttpContext = this.mvcContextFactory.CreateHttpContext();

            // Create a URI with the home page and no query string values.
            var uri = new Uri(currentHttpContext.Request.Url, "/");
            return this.mvcContextFactory.CreateHttpContext(node, uri, writer);
        }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:8,代码来源:SiteMapNodeUrlResolver.cs


示例11: IsVisible

 public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata)
 {
     if (!node.HasChildNodes && !node.Clickable)
     {
         return false;
     }
     return true;
 }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:8,代码来源:TrimEmptyGroupingNodesVisibilityProvider.cs


示例12: IsVisible

        public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata)
        {

            return visability(node, sourceMetadata) & rights(node, sourceMetadata) & module(node, sourceMetadata);



        }
开发者ID:Fonden,项目名称:Natteravnene,代码行数:8,代码来源:ACLMVCSitemap.cs


示例13: IsVisible

        /// <summary>
        /// Determines whether the node is visible.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="sourceMetadata">The source metadata.</param>
        /// <returns>
        /// 	<c>true</c> if the specified node is visible; otherwise, <c>false</c>.
        /// </returns>
        public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata)
        {
            // Is a visibility attribute specified?
            string visibility = string.Empty;
            if (node.Attributes.ContainsKey("visibility"))
            {
                visibility = node.Attributes["visibility"].GetType().Equals(typeof(string)) ? node.Attributes["visibility"].ToString() : string.Empty;
            }
            if (string.IsNullOrEmpty(visibility))
            {
                return true;
            }
            visibility = visibility.Trim();

            string name = string.Empty;
            string htmlHelper = string.Empty;
            if (sourceMetadata.ContainsKey("name"))
            {
                name = Convert.ToString(sourceMetadata["name"]);
            }
            if (sourceMetadata.ContainsKey("HtmlHelper"))
            {
                htmlHelper = Convert.ToString(sourceMetadata["HtmlHelper"]);
            }

            // Check for the source HtmlHelper or given name. If neither are configured,
            // then always visible.
            if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(htmlHelper))
            {
                return true;
            }

            // Chop off the namespace
            htmlHelper = htmlHelper.Substring(htmlHelper.LastIndexOf(".") + 1);

            // Get the keywords
            var visibilityKeywords = visibility.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

            // All set. Now parse the visibility variable.
            foreach (string visibilityKeyword in visibilityKeywords)
            {
                if (visibilityKeyword == htmlHelper || visibilityKeyword == name || visibilityKeyword == "*")
                {
                    return true;
                }
                else if (visibilityKeyword == "IfSelected" && node.IsInCurrentPath())
                {
                    return true;
                }
                else if (visibilityKeyword == "!" + htmlHelper || visibilityKeyword == "!" + name || visibilityKeyword == "!*")
                {
                    return false;
                }
            }

            // Still nothing? Then it's OK!
            return true;
        }
开发者ID:chaoaretasty,项目名称:MvcSiteMapProvider,代码行数:66,代码来源:FilteredSiteMapNodeVisibilityProvider.cs


示例14: ResolveVirtualPath

 protected virtual string ResolveVirtualPath(ISiteMapNode node)
 {
     var url = node.UnresolvedUrl;
     if (!urlPath.IsAbsoluteUrl(url))
     {
         return urlPath.MakeVirtualPathAppAbsolute(urlPath.Combine(urlPath.AppDomainAppVirtualPath, url));
     }
     return url;
 }
开发者ID:chaoaretasty,项目名称:MvcSiteMapProvider,代码行数:9,代码来源:SiteMapNodeUrlResolver.cs


示例15: BuildDynamicNodes

        /// <summary>
        /// Gets the dynamic nodes for node.
        /// </summary>
        /// <param name="node">The SiteMap node.</param>
        /// <param name="defaultParentKey">The key of the parent node.</param>
        public virtual IEnumerable<ISiteMapNodeToParentRelation> BuildDynamicNodes(ISiteMapNode node, string defaultParentKey)
        {
            var result = new List<ISiteMapNodeToParentRelation>();

            if (!node.HasDynamicNodeProvider)
            {
                return result;
            }

            // Get the dynamic nodes using the request's culture context.
            // NOTE: In version 5, we need to use the invariant context and pass a reference to it
            // into the dynamic node provider. This would be a breaking change, so for now we are 
            // swapping the context back to the state of the current request. This way, the end user
            // still can opt to change to invariant culture, but in the reverse situation there would 
            // be no way to identify the culture of the current request without a reference to the 
            // cultureContext object.
            IEnumerable<DynamicNode> dynamicNodes;
            using (var originalCultureContext = this.cultureContextFactory.Create(this.cultureContext.OriginalCulture, this.cultureContext.OriginalUICulture))
            {
                dynamicNodes = node.GetDynamicNodeCollection();
            }

            // Build dynamic nodes
            foreach (var dynamicNode in dynamicNodes)
            {
                // If the dynamic node has a parent key set, use that as the parent. Otherwise use the parentNode.
                var parentKey = !string.IsNullOrEmpty(dynamicNode.ParentKey) ? dynamicNode.ParentKey : defaultParentKey;
                var key = dynamicNode.Key;

                if (string.IsNullOrEmpty(key))
                {
                    key = this.siteMapNodeCreator.GenerateSiteMapNodeKey(
                        parentKey,
                        Guid.NewGuid().ToString(),
                        node.Url,
                        node.Title,
                        node.Area,
                        node.Controller,
                        node.Action,
                        node.HttpMethod,
                        node.Clickable);
                }

                // Create a new node
                var nodeParentMap = this.siteMapNodeCreator.CreateDynamicSiteMapNode(key, parentKey, node.DynamicNodeProvider, node.ResourceKey);
                var newNode = nodeParentMap.Node;

                // Copy the values from the original node to the new one
                node.CopyTo(newNode);

                // Copy any values that were set in the dynamic node and overwrite the new node.
                dynamicNode.SafeCopyTo(newNode);

                result.Add(nodeParentMap);
            }
            return result;
        }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:62,代码来源:DynamicSiteMapNodeBuilder.cs


示例16: SetMvcCodeRoutingContext

        /// <summary>
        /// Adds the MvcCodeRouting.RouteContext DataToken necessary for interoperability 
        /// with the MvcCodeRouting library https://github.com/maxtoroq/MvcCodeRouting
        /// </summary>
        /// <param name="routeData">The route data.</param>
        /// <param name="node">The current site map node.</param>
        internal static void SetMvcCodeRoutingContext(this RouteData routeData, ISiteMapNode node)
        {
            if (routeData == null)
                return;

            var controllerType = node.SiteMap.ResolveControllerType(node.Area, node.Controller);
            var mvcCodeRoutingRouteContext = GetMvcCodeRoutingRouteContext(controllerType, node.Controller);
            routeData.DataTokens["MvcCodeRouting.RouteContext"] = mvcCodeRoutingRouteContext;
        }
开发者ID:modulexcite,项目名称:MvcSiteMapProvider,代码行数:15,代码来源:RouteDataExtensions.cs


示例17: SiteMapHttpRequest

 /// <summary>
 /// Initializes a new instance of the <see cref="SiteMapHttpRequest"/> class.
 /// </summary>
 /// <param name="httpRequest">The object that this wrapper class provides access to.</param>
 /// <param name="node">The site map node to fake node access context for or <c>null</c>.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="httpRequest"/> is null.
 /// </exception>
 public SiteMapHttpRequest(HttpRequest httpRequest, ISiteMapNode node, RequestContext requestContext, Uri nodeUri)
     : base(httpRequest, requestContext)
 {
     this.node = node;
     this.currentRequest = new HttpRequest(
         filename: string.Empty,
         url: nodeUri.ToString(),
         queryString: string.IsNullOrEmpty(nodeUri.Query) ? string.Empty : nodeUri.Query.Substring(1));
 }
开发者ID:yulObraz,项目名称:Test,代码行数:17,代码来源:SiteMapHttpRequest.cs


示例18: SiteMapHttpContext

 /// <summary>
 /// Initializes a new instance of the <see cref="SiteMapHttpContext"/> class.
 /// </summary>
 /// <param name="httpContext">The object that this wrapper class provides access to.</param>
 /// <param name="node">The site map node to fake node access context for or <c>null</c>.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="httpContext"/> is null.
 /// </exception>
 public SiteMapHttpContext(HttpContext httpContext, ISiteMapNode node, Uri uri)
     : base(httpContext)
 {
     this.httpContext = httpContext;
     this.node = node;
     if(node != null) {
         nodeUri = uri ?? new Uri(HttpContext.Current.Request.Url, node.Url);
     }
 }
开发者ID:yulObraz,项目名称:Test,代码行数:17,代码来源:SiteMapHttpContext.cs


示例19: BuildSiteMap

 public ISiteMapNode BuildSiteMap(ISiteMap siteMap, ISiteMapNode rootNode)
 {
     ISiteMapNode result = rootNode;
     foreach (var builder in this.siteMapBuilders)
     {
         result = builder.BuildSiteMap(siteMap, result);
     }
     return result;
 }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:9,代码来源:CompositeSiteMapBuilder.cs


示例20: BuildDynamicNodesFor

        /// <summary>
        /// Adds the dynamic nodes for node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="parentNode">The parent node.</param>
        public IEnumerable<ISiteMapNode> BuildDynamicNodesFor(ISiteMap siteMap, ISiteMapNode node, ISiteMapNode parentNode)
        {
            // List of dynamic nodes that have been created
            var createdDynamicNodes = new List<ISiteMapNode>();

            if (!node.HasDynamicNodeProvider)
            {
                return createdDynamicNodes;
            }

            // Build dynamic nodes
            foreach (var dynamicNode in node.GetDynamicNodeCollection())
            {
                string key = dynamicNode.Key;
                if (string.IsNullOrEmpty(key))
                {
                    key = nodeKeyGenerator.GenerateKey(
                        parentNode == null ? "" : parentNode.Key, 
                        Guid.NewGuid().ToString(), 
                        node.Url, 
                        node.Title, 
                        node.Area, 
                        node.Controller, 
                        node.Action,
                        node.HttpMethod,
                        node.Clickable);
                }

                // Create a new node
                var newNode = siteMapNodeFactory.CreateDynamic(siteMap, key, node.ResourceKey);

                // Copy the values from the original node to the new one
                node.CopyTo(newNode);

                // Copy any values that were set in the dynamic node and overwrite the new node.
                dynamicNode.SafeCopyTo(newNode);

                // If the dynamic node has a parent key set, use that as the parent. Otherwise use the parentNode.
                if (!string.IsNullOrEmpty(dynamicNode.ParentKey))
                {
                    var parent = siteMap.FindSiteMapNodeFromKey(dynamicNode.ParentKey);
                    if (parent != null)
                    {
                        siteMap.AddNode(newNode, parent);
                        createdDynamicNodes.Add(newNode);
                    }
                }
                else
                {
                    siteMap.AddNode(newNode, parentNode);
                    createdDynamicNodes.Add(newNode);
                }
            }

            // Done!
            return createdDynamicNodes;
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:62,代码来源:DynamicNodeBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISiteService类代码示例发布时间:2022-05-24
下一篇:
C# ISiteMap类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap