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


C# ISiteMapNode类代码示例

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


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


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