本文整理汇总了C#中IWebHelper.QueryString方法的典型用法代码示例。如果您正苦于以下问题:C# IWebHelper.QueryString方法的具体用法?C# IWebHelper.QueryString怎么用?C# IWebHelper.QueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebHelper
的用法示例。
在下文中一共展示了IWebHelper.QueryString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_get_queryString
public void Can_get_queryString()
{
var queryStringParams = new NameValueCollection();
queryStringParams.Add("Key1", "Value1");
queryStringParams.Add("Key2", "Value2");
_httpContext = new FakeHttpContext("~/", "GET", null, null, queryStringParams, null, null, null);
_webHelper = new WebHelper(_httpContext);
_webHelper.QueryString<string>("Key1").ShouldEqual("Value1");
_webHelper.QueryString<string>("Key2").ShouldEqual("Value2");
_webHelper.QueryString<string>("Key3").ShouldEqual(null);
}
示例2: GetAlreadyFilteredSpecOptionIds
public virtual List<int> GetAlreadyFilteredSpecOptionIds(IWebHelper webHelper)
{
var result = new List<int>();
var alreadyFilteredSpecsStr = webHelper.QueryString<string>(QUERYSTRINGPARAM);
if (String.IsNullOrWhiteSpace(alreadyFilteredSpecsStr))
return result;
foreach (var spec in alreadyFilteredSpecsStr.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
int specId;
int.TryParse(spec.Trim(), out specId);
if (!result.Contains(specId))
result.Add(specId);
}
return result;
}
示例3: GetSelectedPriceRange
public virtual PriceRange GetSelectedPriceRange(IWebHelper webHelper, string priceRangesStr)
{
var range = webHelper.QueryString<string>(QUERYSTRINGPARAM);
if (String.IsNullOrEmpty(range))
return null;
string[] fromTo = range.Trim().Split(new [] { '-' });
if (fromTo.Length == 2)
{
decimal? from = null;
if (!String.IsNullOrEmpty(fromTo[0]) && !String.IsNullOrEmpty(fromTo[0].Trim()))
from = decimal.Parse(fromTo[0].Trim(), new CultureInfo("en-US"));
decimal? to = null;
if (!String.IsNullOrEmpty(fromTo[1]) && !String.IsNullOrEmpty(fromTo[1].Trim()))
to = decimal.Parse(fromTo[1].Trim(), new CultureInfo("en-US"));
var priceRangeList = GetPriceRangeList(priceRangesStr);
foreach (var pr in priceRangeList)
{
if (pr.From == from && pr.To == to)
return pr;
}
}
return null;
}