本文整理匯總了C#中System.UriBuilder.AddQueryParams方法的典型用法代碼示例。如果您正苦於以下問題:C# UriBuilder.AddQueryParams方法的具體用法?C# UriBuilder.AddQueryParams怎麽用?C# UriBuilder.AddQueryParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.UriBuilder
的用法示例。
在下文中一共展示了UriBuilder.AddQueryParams方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UriBuilderExtensionsTest_AddQueryParameters_ExistingQuery_ValidateQueryParams
public void UriBuilderExtensionsTest_AddQueryParameters_ExistingQuery_ValidateQueryParams()
{
var uriBuidler = new UriBuilder();
uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2";
uriBuidler.AddQueryParams(
new RequestParameter("Name3", "Value3"),
new RequestParameter("Name4", "Value4"),
new RequestParameter("Name5", "Value5"),
new RequestParameter("Name6", "Value6")
);
var qp = uriBuidler.GetQueryParams();
Assert.AreEqual("Name", qp[0].Name);
Assert.AreEqual("Value", qp[0].Value);
Assert.AreEqual("Name1", qp[1].Name);
Assert.AreEqual("Value1", qp[1].Value);
Assert.AreEqual("Name2", qp[2].Name);
Assert.AreEqual("Value2", qp[2].Value);
Assert.AreEqual("Name3", qp[3].Name);
Assert.AreEqual("Value3", qp[3].Value);
Assert.AreEqual("Name4", qp[4].Name);
Assert.AreEqual("Value4", qp[4].Value);
Assert.AreEqual("Name5", qp[5].Name);
Assert.AreEqual("Value5", qp[5].Value);
Assert.AreEqual("Name6", qp[6].Name);
Assert.AreEqual("Value6", qp[6].Value);
}
示例2: UriBuilderExtensionsTest_AddQueryParameters_ExistingEmptyQuery_ValidateQueryString
public void UriBuilderExtensionsTest_AddQueryParameters_ExistingEmptyQuery_ValidateQueryString()
{
var uriBuidler = new UriBuilder();
uriBuidler.AddQueryParams(
new RequestParameter("Name3", "Value3"),
new RequestParameter("Name4", "Value4"),
new RequestParameter("Name5", "Value5"),
new RequestParameter("Name6", "Value6")
);
var qp = uriBuidler.GetQueryParams();
Assert.AreEqual("?Name3=Value3&Name4=Value4&Name5=Value5&Name6=Value6", uriBuidler.Query, "Query string does not match.!");
}
示例3: UriBuilderExtensionsTest_ClearQueryParameters_ValidateQueryString_ValidateQueryParams
public void UriBuilderExtensionsTest_ClearQueryParameters_ValidateQueryString_ValidateQueryParams()
{
var uriBuidler = new UriBuilder();
uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2";
uriBuidler.AddQueryParams(
new RequestParameter("Name3", "Value3"),
new RequestParameter("Name4", "Value4"),
new RequestParameter("Name5", "Value5"),
new RequestParameter("Name6", "Value6")
);
uriBuidler.ClearQueryParams();
var qp = uriBuidler.GetQueryParams();
Assert.IsTrue(uriBuidler.Query.Length == 0);
}
示例4: UriBuilderExtensionsTest_AddQueryParameters_InvalidInput_ThrowsException
public void UriBuilderExtensionsTest_AddQueryParameters_InvalidInput_ThrowsException()
{
var uriBuidler = new UriBuilder();
uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2";
try
{
uriBuidler.AddQueryParams(null);
}
catch (ArgumentNullException) { return; }
Assert.Fail("Expecting ArgumentNullException!");
}