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


C# Url.AppendQuery方法代码示例

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


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

示例1: GetEditNewPageUrl

        /// <summary>Gets the url to edit page creating new items.</summary>
        /// <param name="selected">The selected item.</param>
        /// <param name="definition">The type of item to edit.</param>
        /// <param name="zoneName">The zone to add the item to.</param>
        /// <param name="position">The position relative to the selected item to add the item.</param>
        /// <returns>The url to the edit page.</returns>
        public string GetEditNewPageUrl(ContentItem selected, ContentType definition, string zoneName, CreationPosition position)
        {
            if (selected == null) throw new ArgumentNullException("selected");
            if (definition == null) throw new ArgumentNullException("definition");

            ContentItem parent = (position != CreationPosition.Below) ? selected.Parent : selected;

            if (selected == null)
                throw new ZeusException("Cannot insert item before or after the root page.");

            Url url = new Url(EditItemUrl);
            url = url.AppendQuery("selected", parent.Path);
            url = url.AppendQuery("discriminator", definition.Discriminator);
            url = url.AppendQuery("zoneName", zoneName);

            switch (position)
            {
                case CreationPosition.Before:
                    url = url.AppendQuery("before", selected.Path);
                    break;
                case CreationPosition.After:
                    url = url.AppendQuery("after", selected.Path);
                    break;
            }

            return url.ToString();
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:33,代码来源:AdminManager.cs

示例2: FormatSelectedUrl

 private static string FormatSelectedUrl(ContentItem selectedItem, string path)
 {
     Url url = new Url(path);
     if (selectedItem != null)
         url = url.AppendQuery("selected=" + selectedItem.Path);
     return url.ToString();
 }
开发者ID:dpawatts,项目名称:zeus,代码行数:7,代码来源:AdminManager.cs

示例3: BuildUrlInternal

        protected string BuildUrlInternal(ContentItem item, string languageCode, out ContentItem startPage)
        {
            startPage = null;
            ContentItem current = item;
            Url url = new Url("/");

            // Walk the item's parent items to compute it's url
            do
            {
                if (IsStartPage(current))
                {
                    startPage = current;

                    if (item.VersionOf != null)
                        url = url.AppendQuery(PathData.PageQueryKey, item.ID);

                    // Prepend language identifier, if this is not the default language.
                    if (_languageManager.Enabled && !LanguageSelection.IsHostLanguageMatch(ContentLanguage.PreferredCulture.Name))
                    {
                        if (LanguageSelection.GetHostFromLanguage(ContentLanguage.PreferredCulture.Name) != _webContext.LocalUrl.Authority)
                            url = url.SetAuthority(LanguageSelection.GetHostFromLanguage(ContentLanguage.PreferredCulture.Name));
                        else if (!string.IsNullOrEmpty(languageCode))
                            url = url.PrependSegment(languageCode, true);
                    }

                    // we've reached the start page so we're done here
                    return VirtualPathUtility.ToAbsolute("~" + url.PathAndQuery);
                }

                url = url.PrependSegment(current.Name, current.Extension);

                current = current.GetParent(languageCode);
            } while (current != null);

            // If we didn't find the start page, it means the specified
            // item is not part of the current site.
            return "/?" + PathData.PageQueryKey + "=" + item.ID;
            //return item.FindPath(PathData.DefaultAction).RewrittenUrl;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:39,代码来源:UrlParser.cs


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