本文整理汇总了C#中QueryString.Add方法的典型用法代码示例。如果您正苦于以下问题:C# QueryString.Add方法的具体用法?C# QueryString.Add怎么用?C# QueryString.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryString
的用法示例。
在下文中一共展示了QueryString.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldBuildHttpPostString
public void ShouldBuildHttpPostString()
{
// arrange
QueryString qs = new QueryString();
qs.Add("1", "2");
qs.Add("3", "4");
// act and assert
Assert.AreEqual("1=2&3=4", qs.ToString(HttpAction.Post));
}
示例2: Process
public ActionResult Process(HttpRequestBase request, ModelStateDictionary modelState)
{
IpnVerificationBinder binder = new IpnVerificationBinder();
Transaction tx = binder.Bind(request.Form, modelState);
ContentResult cr = new ContentResult();
cr.ContentEncoding = Encoding.UTF8;
cr.ContentType = "text/html";
cr.Content = "INVALID";
if (tx != null)
{
Transaction dbTx = m_txRepository.GetAll().Where(x => x.Tx == tx.Tx).FirstOrDefault();
if (dbTx != null)
{
string expected = dbTx.ToIpnQueryString().ToString();
QueryString actualQs = new QueryString();
actualQs.Add(request.Form);
actualQs.Remove("cmd");
string actual = actualQs.ToString();
if (expected == actual)
{
cr.Content = "VERIFIED";
}
}
}
return cr;
}
示例3: MyFact
public void MyFact()
{
var queryString = new QueryString();
queryString.Add("q", "mcdonald");
Assert.Equal("q=mcdonald", queryString.ToString());
}
示例4: ShouldEncodeWhenConvertingToString
public void ShouldEncodeWhenConvertingToString()
{
// arrange
QueryString qs = new QueryString();
qs.Add("1", "http://");
// act and assert
Assert.AreEqual("?1=http%3a%2f%2f", qs.ToString());
}
示例5: ShouldNotEncodeWhenAdding
public void ShouldNotEncodeWhenAdding()
{
// arrange
QueryString qs = new QueryString();
qs.Add("1", "http://");
// act and assert
Assert.AreEqual("http://", qs["1"]);
}
示例6: ShouldDecodeWhenGettingValue
public void ShouldDecodeWhenGettingValue()
{
// arrange
QueryString qs = new QueryString();
qs.Add("1", "http%3a%2f%2f");
// act and assert
Assert.AreEqual("http://", qs["1"]);
}
示例7: Delete
/// <summary>
/// 删除一个Catalog
/// </summary>
/// <param name="catalogId">Catalog的唯一标识</param>
public void Delete(Int32 catalogId)
{
var qs = new QueryString();
qs.Add("catalogId", catalogId.ToString());
var deleteCata = client.HttpPost("/catalog/delete.api", qs);
var jo = JObject.Parse(deleteCata);
if (jo["statusCode"].ToString().CompareTo("0") != 0)
{
throw new PispowerAPIException(System.Int32.Parse(jo["statusCode"].ToString()), jo["message"].ToString());
}
}
示例8: GetCdnDedicatedQuotas
/// <summary>
/// Return quota history
/// <param name="period">To be written</param>
/// <param name="serviceName">The internal name of your CDN offer</param>
/// </summary>
public async Task<OvhApi.Models.Cdnanycast.StatsDataType[]> GetCdnDedicatedQuotas(OvhApi.Models.Cdnanycast.StatsPeriodEnum period,string serviceName)
{
if(ConsumerKey == null)
throw new OvhException("This request must be authenticated");
Ensure.NotNull("period",period);
Ensure.NotNullNorEmpty("serviceName",serviceName);
var queryString = new QueryString();
queryString.Add("period",period);
return await RawCall<OvhApi.Models.Cdnanycast.StatsDataType[]>(HttpMethod.Get,String.Format("/cdn/dedicated/{0}/quota{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString));
}
示例9: Add
internal static string Add(this PathString path, object value)
{
var parameters = value.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(value)?.ToString())
.Where(x => x.Value.IsNotNullOrWhiteSpace());
var query = new QueryString();
foreach(var parameter in parameters) {
query = query.Add(parameter.Key, parameter.Value);
}
return path.Add(query);
}
示例10: EncryptQueryString
public static QueryString EncryptQueryString(QueryString queryString)
{
QueryString newQueryString = new QueryString();
string nm = String.Empty;
string val = String.Empty;
foreach (string name in queryString)
{
nm = name;
val = queryString[name];
newQueryString.Add(Encryption.Hex(nm),Encryption.Hex(val));
}
return newQueryString;
}
示例11: DecryptQueryString
public static QueryString DecryptQueryString(QueryString queryString)
{
QueryString newQueryString = new QueryString();
string nm;
string val;
foreach (string name in queryString)
{
nm = Encryption.DeHex(name);
val = Encryption.DeHex(queryString[name]);
newQueryString.Add(nm, val);
}
return newQueryString;
}
示例12: CreateSignedUrl
private string CreateSignedUrl()
{
SignedRequestHelper helper = new SignedRequestHelper(Configuration.AWSAccessKeyId, Configuration.AWSSecretAccessKey, Constants.AWSUrl);
QueryString query = new QueryString();
query.Add("Service", "AWSECommerceService");
query.Add("AssociateTag", Configuration.AWSAID);
query.Add("Version", "2011-08-01");
query.Add("ResponseGroup", "Images,Small");
query.Add("Operation", "ItemSearch");
query.Add("SearchIndex", ItemType.ToString());
query.Add(SearchType.ToString(), Uri.EscapeDataString(Keywords));
var signedUrl = helper.Sign(query);
return signedUrl;
}
示例13: Add
/// <summary>
/// 增加一个Catalog
/// </summary>
/// <param name="name">Catalog的名字</param>
/// <returns>Catalog 包含id,name字段,但videoNumber字段的值为空</returns>
public Catalog Add(String name)
{
var qs = new QueryString();
qs.Add("name", name);
var createCata = client.HttpPost("/catalog/create.api", qs);
var jo = JObject.Parse(createCata);
if (jo["statusCode"].ToString().CompareTo("0") == 0)
{
var cata = new Catalog();
cata.Name = jo["name"].ToString();
var id = jo["id"].ToString();
cata.Id = System.Int32.Parse(id);
return cata;
}
else
{
throw new PispowerAPIException(System.Int32.Parse(jo["statusCode"].ToString()), jo["message"].ToString());
}
}
示例14: Get
/// <summary>
/// 根据id查询Catalog
/// </summary>
/// <param name="catalogId">Catalog的唯一标识</param>
/// <returns>Catalog 包含name,videoNumber字段, 但id字段的值为空</returns>
public Catalog Get(Int32 catalogId)
{
QueryString qs = new QueryString();
qs.Add("catalogId", catalogId.ToString());
var getCata = client.HttpGet("/catalog/get.api", qs);
var jo = JObject.Parse(getCata);
if (jo["statusCode"].ToString().CompareTo("0") == 0)
{
Console.WriteLine("name:" + jo["name"]);
var cata = new Catalog();
cata.Name = jo["name"].ToString();
var videoNum = jo["videoNumber"].ToString();
cata.VideoNumber = System.Int32.Parse(videoNum);
return cata;
}
else
{
throw new PispowerAPIException(System.Int32.Parse(jo["statusCode"].ToString()), jo["message"].ToString());
}
}
示例15: GetHostingWebOffercapabilities
/// <summary>
/// Get offer capabilities
/// <param name="offer">Describe offer capabilities</param>
/// </summary>
public async Task<OvhApi.Models.Hosting.Web.Capabilities> GetHostingWebOffercapabilities(OvhApi.Models.Hosting.Web.OfferCapabilitiesEnum offer)
{
if(ConsumerKey == null)
throw new OvhException("This request must be authenticated");
Ensure.NotNull("offer",offer);
var queryString = new QueryString();
queryString.Add("offer",offer);
return await RawCall<OvhApi.Models.Hosting.Web.Capabilities>(HttpMethod.Get,String.Format("/hosting/web/offerCapabilities{0}",queryString));
}