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


C# ISiteMap类代码示例

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


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

示例1: SeoRouteValueDictionary

 public SeoRouteValueDictionary(string siteMapNodeKey, string memberName, ISiteMap siteMap,
     IReservedAttributeNameProvider reservedAttributeNameProvider,
     IJsonToDictionaryDeserializer jsonToDictionaryDeserializer, ICache cache)
     : base(
         siteMapNodeKey, memberName, siteMap, reservedAttributeNameProvider, jsonToDictionaryDeserializer, cache)
 {
 }
开发者ID:Wdovin,项目名称:vc-community,代码行数:7,代码来源:SeoRouteValueDictionary.cs

示例2: SiteMapNodeHelper

        public SiteMapNodeHelper(
            ISiteMap siteMap,
            ICultureContext cultureContext,
            ISiteMapNodeCreatorFactory siteMapNodeCreatorFactory,
            IDynamicSiteMapNodeBuilderFactory dynamicSiteMapNodeBuilderFactory,
            IReservedAttributeNameProvider reservedAttributeNameProvider,
            ICultureContextFactory cultureContextFactory
            )
        {
            if (siteMap == null)
                throw new ArgumentNullException("siteMap");
            if (cultureContext == null)
                throw new ArgumentNullException("cultureContext");
            if (siteMapNodeCreatorFactory == null)
                throw new ArgumentNullException("siteMapNodeCreatorFactory");
            if (dynamicSiteMapNodeBuilderFactory == null)
                throw new ArgumentNullException("dynamicSiteMapNodeBuilderFactory");
            if (reservedAttributeNameProvider == null)
                throw new ArgumentNullException("reservedAttributeNameProvider");
            if (cultureContextFactory == null)
                throw new ArgumentNullException("cultureContextFactory");

            this.siteMap = siteMap;
            this.cultureContext = cultureContext;
            this.siteMapNodeCreatorFactory = siteMapNodeCreatorFactory;
            this.dynamicSiteMapNodeBuilderFactory = dynamicSiteMapNodeBuilderFactory;
            this.reservedAttributeNameProvider = reservedAttributeNameProvider;
            this.cultureContextFactory = cultureContextFactory;
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:29,代码来源:SiteMapNodeHelper.cs

示例3: 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

示例4: BuildHierarchy

        public IEnumerable<ISiteMapNodeToParentRelation> BuildHierarchy(ISiteMap siteMap, IEnumerable<ISiteMapNodeToParentRelation> nodes)
        {
            var sourceNodesByParent = nodes.ToLookup(n => n.ParentKey);
            var sourceNodes = new List<ISiteMapNodeToParentRelation>(nodes);
            var nodesAddedThisIteration = 0;
            do
            {
                var nodesAlreadyAdded = new HashSet<string>();
                nodesAddedThisIteration = 0;
                foreach (var node in sourceNodes.OrderBy(x => x.Node.Order).ToArray())
                {
                    if (nodesAlreadyAdded.Contains(node.Node.Key))
                    {
                        continue;
                    }

                    var parentNode = siteMap.FindSiteMapNodeFromKey(node.ParentKey);
                    if (parentNode != null)
                    {
                        this.AddAndTrackNode(siteMap, node, parentNode, sourceNodes, nodesAlreadyAdded);
                        nodesAddedThisIteration += 1;

                        // Add the rest of the tree branch below the current node
                        this.AddDescendantNodes(siteMap, node.Node, sourceNodes, sourceNodesByParent, nodesAlreadyAdded);
                    }
                }
            }
            while (nodesAddedThisIteration > 0 && sourceNodes.Count > 0);

            return sourceNodes;
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:31,代码来源:SiteMapHierarchyBuilder.cs

示例5: 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

示例6: SiteMapNodeHelper

        public SiteMapNodeHelper(
            string siteMapCacheKey,
            ISiteMap siteMap,
            ISiteMapNodeCreatorFactory siteMapNodeCreatorFactory,
            IDynamicSiteMapNodeBuilderFactory dynamicSiteMapNodeBuilderFactory,
            ISiteMapXmlReservedAttributeNameProvider reservedAttributeNameProvider
            )
        {
            if (String.IsNullOrEmpty(siteMapCacheKey))
                throw new ArgumentNullException("siteMapCacheKey");
            if (siteMap == null)
                throw new ArgumentNullException("siteMap");
            if (siteMapNodeCreatorFactory == null)
                throw new ArgumentNullException("siteMapNodeCreatorFactory");
            if (dynamicSiteMapNodeBuilderFactory == null)
                throw new ArgumentNullException("dynamicSiteMapNodeBuilderFactory");
            if (reservedAttributeNameProvider == null)
                throw new ArgumentNullException("reservedAttributeNameProvider");

            this.siteMapCacheKey = siteMapCacheKey;
            this.siteMap = siteMap;
            this.siteMapNodeCreatorFactory = siteMapNodeCreatorFactory;
            this.dynamicSiteMapNodeBuilderFactory = dynamicSiteMapNodeBuilderFactory;
            this.reservedAttributeNameProvider = reservedAttributeNameProvider;
        }
开发者ID:chaoaretasty,项目名称:MvcSiteMapProvider,代码行数:25,代码来源:SiteMapNodeHelper.cs

示例7: GetCurrentNode

        /// <summary>
        /// This determines the deepest node matching the current HTTP context, so if the current URL describes a location
        /// deeper than the site map designates, it will determine the closest parent to the current URL and return that 
        /// as the current node. This allows menu relevence when navigating deeper than the sitemap structure designates, such
        /// as when navigating to MVC actions, which are not shown in the menus
        /// </summary>
        /// <param name="selectedSiteMapProvider">the current MVC Site Map Provider</param>
        /// <returns></returns>
        public static ISiteMapNode GetCurrentNode(ISiteMap selectedSiteMap)
        {
            // get the node matching the current URL location
            var currentNode = selectedSiteMap.CurrentNode;

            // if there is no node matching the current URL path,
            // remove parts until we get a hit
            if (currentNode == null)
            {
                var url = HttpContext.Current.Request.Url.LocalPath;

                while (url.Length > 0)
                {
                    // see if we can find a matching node
                    currentNode = selectedSiteMap.FindSiteMapNode(url);

                    // if we get a hit, stop
                    if (currentNode != null) break;

                    // if not, remove the last path item
                    var lastSlashlocation = url.LastIndexOf("/");
                    if (lastSlashlocation < 0) break; // protects us from malformed URLs
                    url = url.Remove(lastSlashlocation);
                }
            }

            return currentNode;
        }
开发者ID:pickist,项目名称:MvcSiteMapProvider,代码行数:36,代码来源:MenuHelper.cs

示例8: Create

 public ISiteMapNodeCreator Create(ISiteMap siteMap)
 {
     return new SiteMapNodeCreator(
         siteMap, 
         this.siteMapNodeFactory, 
         this.nodeKeyGenerator, 
         this.siteMapNodeToParentRelationFactory);
 }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:8,代码来源:SiteMapNodeCreatorFactory.cs

示例9: 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

示例10: 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

示例11: Create

 public ISiteMapNodeHelper Create(ISiteMap siteMap, string siteMapCacheKey)
 {
     return new SiteMapNodeHelper(
         siteMapCacheKey,
         siteMap,
         this.siteMapNodeCreatorFactory,
         this.dynamicSiteMapNodeBuilderFactory,
         this.reservedAttributeNameProvider);
 }
开发者ID:chaoaretasty,项目名称:MvcSiteMapProvider,代码行数:9,代码来源:SiteMapNodeHelperFactory.cs

示例12: BuildSiteMap

        public virtual ISiteMapNode BuildSiteMap(ISiteMap siteMap, ISiteMapNode rootNode)
        {
            if (rootNode == null)
            {
                throw new ArgumentNullException("rootNode", Resources.Messages.VisitingSiteMapBuilderRequiresRootNode);
            }

            VisitNodes(rootNode);
            return rootNode;
        }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:10,代码来源:VisitingSiteMapBuilder.cs

示例13: Create

 public ISiteMapNodeHelper Create(ISiteMap siteMap, ICultureContext cultureContext)
 {
     return new SiteMapNodeHelper(
         siteMap,
         cultureContext,
         this.siteMapNodeCreatorFactory,
         this.dynamicSiteMapNodeBuilderFactory,
         this.reservedAttributeNameProvider,
         this.cultureContextFactory);
 }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:10,代码来源:SiteMapNodeHelperFactory.cs

示例14: BuildSiteMap

        public virtual ISiteMapNode BuildSiteMap(ISiteMap siteMap, ISiteMapNode rootNode)
        {
            var xml = xmlSource.GetXml();
            if (xml != null)
            {
                rootNode = LoadSiteMapFromXml(siteMap, xml);
            }

            // Done!
            return rootNode;
        }
开发者ID:agrynco,项目名称:MvcSiteMapProvider,代码行数:11,代码来源:XmlSiteMapBuilder.cs

示例15: 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 virtual bool IsAccessibleToUser(ISiteMap siteMap, ISiteMapNode node)
 {
     foreach (var module in aclModules)
     {
         var authorized = module.IsAccessibleToUser(siteMap, node);
         if (authorized == false)
             return false;
     }
     // Convention throughout the provider: if the IAclModule can not authenticate a user, true is returned.
     return true;
 }
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:19,代码来源:CompositeAclModule.cs


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