本文整理汇总了C#中Url.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Url.ToString方法的具体用法?C# Url.ToString怎么用?C# Url.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}