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


C# UrlHelper.GetUmbracoApiService方法代码示例

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


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

示例1: ConvertFromLegacy

        /// <summary>
        /// Converts a legacy XmlTreeNode to a new TreeNode
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="xmlTreeNode"></param>
        /// <param name="urlHelper"></param>
        /// <param name="currentSection"></param>
        /// <param name="currentQueryStrings">
        /// The current query strings for the request - this is used to append the query strings to the menu URL of the item being rendered since the menu
        /// actually belongs to this same node (request) the query strings need to exist so the menu can be rendered in some cases.
        /// </param>
        /// <param name="isRoot"></param>
        /// <returns></returns>
        internal static TreeNode ConvertFromLegacy(string parentId, XmlTreeNode xmlTreeNode, UrlHelper urlHelper, string currentSection, FormDataCollection currentQueryStrings, bool isRoot = false)
        {
            //  /umbraco/tree.aspx?rnd=d0d0ff11a1c347dabfaa0fc75effcc2a&id=1046&treeType=content&contextMenu=false&isDialog=false

            //we need to convert the node source to our legacy tree controller
            var childNodesSource = urlHelper.GetUmbracoApiService<LegacyTreeController>("GetNodes");

            var childQuery = (xmlTreeNode.Source.IsNullOrWhiteSpace() || xmlTreeNode.Source.IndexOf('?') == -1)
                ? ""
                : xmlTreeNode.Source.Substring(xmlTreeNode.Source.IndexOf('?'));

            //append the query strings
            childNodesSource = childNodesSource.AppendQueryStringToUrl(childQuery);

            //for the menu source we need to detect if this is a root node since we'll need to set the parentId and id to -1
            // for which we'll handle correctly on the server side.            
            //if there are no menu items, then this will be empty
            var menuSource = "";
            if (xmlTreeNode.Menu != null && xmlTreeNode.Menu.Any())
            {
                menuSource = urlHelper.GetUmbracoApiService<LegacyTreeController>("GetMenu");
                //these are the absolute required query strings
                var menuQueryStrings = new Dictionary<string, object>
                    {
                        {"id", (isRoot ? "-1" : xmlTreeNode.NodeID)},
                        {"treeType", xmlTreeNode.TreeType},
                        {"parentId", (isRoot ? "-1" : parentId)},
                        {"section", currentSection}
                    };
                //append the extra ones on this request
                foreach (var i in currentQueryStrings.Where(x => menuQueryStrings.Keys.Contains(x.Key) == false))
                {
                    menuQueryStrings.Add(i.Key, i.Value);
                }
                
                menuSource = menuSource.AppendQueryStringToUrl(menuQueryStrings.ToQueryString());    
            }
            

            //TODO: Might need to add stuff to additional attributes

            var node = new TreeNode(xmlTreeNode.NodeID, isRoot ? null : parentId, childNodesSource, menuSource)
            {
                HasChildren = xmlTreeNode.HasChildren,
                Icon = xmlTreeNode.Icon,
                Name = xmlTreeNode.Text,
                NodeType = xmlTreeNode.NodeType
            };
            if (isRoot)
            {
                node.AdditionalData.Add("treeAlias", xmlTreeNode.TreeType);
            }

            //This is a special case scenario, we know that content/media works based on the normal Belle routing/editing so we'll ensure we don't
            // pass in the legacy JS handler so we do it the new way, for all other trees (Currently, this is a WIP), we'll render
            // the legacy js callback,.
            var knownNonLegacyNodeTypes = new[] { "content", "contentRecycleBin", "mediaRecyleBin", "media" };
            if (knownNonLegacyNodeTypes.InvariantContains(xmlTreeNode.NodeType) == false)
            {
                node.AssignLegacyJsCallback(xmlTreeNode.Action);
            }
            return node;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:76,代码来源:LegacyTreeDataConverter.cs


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