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


C# ISiteMapNode.GetDynamicNodeCollection方法代码示例

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


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

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

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

示例3: BuildDynamicNodes

        /// <summary>
        /// Gets the dynamic nodes for node.
        /// </summary>
        /// <param name="siteMap">The site map.</param>
        /// <param name="node">The node.</param>
        /// <param name="parentKey">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;
            }

            // Build dynamic nodes
            foreach (var dynamicNode in node.GetDynamicNodeCollection())
            {
                // 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:chaoaretasty,项目名称:MvcSiteMapProvider,代码行数:50,代码来源:DynamicSiteMapNodeBuilder.cs


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