本文整理匯總了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"));
}