本文整理汇总了C#中N2.Web.Url.SetQueryParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Url.SetQueryParameter方法的具体用法?C# Url.SetQueryParameter怎么用?C# Url.SetQueryParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类N2.Web.Url
的用法示例。
在下文中一共展示了Url.SetQueryParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResizedImageUrl
/// <summary>Returns the path to an image handler that resizes the given image to the appropriate size.</summary>
/// <param name="imageUrl">The image to resize.</param>
/// <param name="width">The maximum width.</param>
/// <param name="height">The maximum height.</param>
/// <returns>The path to a handler that performs resizing of the image.</returns>
public static string GetResizedImageUrl(string imageUrl, double width, double height)
{
// TODO: Refactor to HtmlHelper extension
string fileExtension = VirtualPathUtility.GetExtension(N2.Web.Url.PathPart(imageUrl));
bool isAlreadyImageHandler = string.Equals(fileExtension, ".ashx", StringComparison.OrdinalIgnoreCase);
if (isAlreadyImageHandler) return N2.Web.Url.ToAbsolute(imageUrl);
Url url = new Url("~/Image.ashx").SetQueryParameter("img", N2.Web.Url.ToAbsolute(imageUrl));
if (width > 0) url = url.SetQueryParameter("w", (int) width);
if (height > 0) url = url.SetQueryParameter("h", (int) height);
return url;
}
示例2: UpdateQuery
public Url UpdateQuery(IDictionary<string,object> queryString)
{
Url u = new Url(this);
foreach (KeyValuePair<string,object> pair in queryString)
if(pair.Value != null)
u = u.SetQueryParameter(pair.Key, pair.Value.ToString());
return u;
}
示例3: UpdatingQueryToNull_ReturnsOtherParameters_WhenUpdatingLast
public void UpdatingQueryToNull_ReturnsOtherParameters_WhenUpdatingLast()
{
Url u = new Url("/hello.aspx?something=someotherthing&query=value&query3=value3");
u = u.SetQueryParameter("query3", null);
Assert.That(u.ToString(), Is.EqualTo("/hello.aspx?something=someotherthing&query=value"));
}
示例4: UpdatingQueryToNull_WhenSingleParameter_RemovesItFromUrl
public void UpdatingQueryToNull_WhenSingleParameter_RemovesItFromUrl()
{
Url u = new Url("/hello.aspx?something=someotherthing");
u = u.SetQueryParameter("something", null);
Assert.That(u.ToString(), Is.EqualTo("/hello.aspx"));
}