本文整理汇总了C#中System.Uri.GetQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.GetQueryString方法的具体用法?C# Uri.GetQueryString怎么用?C# Uri.GetQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了Uri.GetQueryString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldReturnStringKeyValuePair
public void ShouldReturnStringKeyValuePair()
{
var uri = new Uri("http://google.com?key=value", UriKind.Absolute);
var pairs = uri.GetQueryString();
pairs.Count().ShouldBe(1);
pairs.ElementAt(0).Key.ShouldBe("key");
pairs.ElementAt(0).Value.ShouldBe("value");
}
示例2: ShouldContainClassNamesFromQueryString
public void ShouldContainClassNamesFromQueryString()
{
var uri = new Uri("/TestHarness.htm?xap=One&Class=NS.Class&class= Class2.&CLASS= &class=Class3 ", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.ClassNames.Count().ShouldBe(3);
model.ClassNames.ElementAt(0).ShouldBe("NS.Class");
model.ClassNames.ElementAt(1).ShouldBe("Class2.");
model.ClassNames.ElementAt(2).ShouldBe("Class3");
}
示例3: ShouldReturnKeysOnlyInQueryString
public void ShouldReturnKeysOnlyInQueryString()
{
var uri = new Uri("/Default.aspx?key1&key2&key3", UriKind.Relative);
var pairs = uri.GetQueryString();
pairs.Count().ShouldBe(3);
pairs.ElementAt(0).Key.ShouldBe("key1");
pairs.ElementAt(1).Key.ShouldBe("key2");
pairs.ElementAt(2).Key.ShouldBe("key3");
}
示例4: ShouldContainXapFilesFromQueryString
public void ShouldContainXapFilesFromQueryString()
{
var uri = new Uri("/TestHarness.htm?xap=One&XAP=Two...xap&xap=Three.&xap=Four.XAP&xap= ", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.XapFiles.Count().ShouldBe(4);
model.XapFiles.ElementAt(0).ShouldBe("One");
model.XapFiles.ElementAt(1).ShouldBe("Two");
model.XapFiles.ElementAt(2).ShouldBe("Three");
model.XapFiles.ElementAt(3).ShouldBe("Four");
}
示例5: ShouldReturnQueryStringThatContainsQuestionMark
public void ShouldReturnQueryStringThatContainsQuestionMark()
{
var uri = new Uri("/Default.aspx?key?=value&key=valu?e", UriKind.Relative);
var pairs = uri.GetQueryString();
pairs.Count().ShouldBe(2);
pairs.ElementAt(0).Key.ShouldBe("key?");
pairs.ElementAt(0).Value.ShouldBe("value");
pairs.ElementAt(1).Key.ShouldBe("key");
pairs.ElementAt(1).Value.ShouldBe("valu?e");
}
示例6: ShouldHaveQueryStringOnRelativeUri
public void ShouldHaveQueryStringOnRelativeUri()
{
var uri = new Uri("/Default.aspx?key=value&key=value", UriKind.Relative);
var pairs = uri.GetQueryString();
pairs.Count().ShouldBe(2);
pairs.ElementAt(0).Key.ShouldBe("key");
pairs.ElementAt(0).Value.ShouldBe("value");
pairs.ElementAt(1).Key.ShouldBe("key");
pairs.ElementAt(1).Value.ShouldBe("value");
}
示例7: ShouldHaveQueryStringOnAbsoluteUri
public void ShouldHaveQueryStringOnAbsoluteUri()
{
var uri = new Uri("http://google.com?key=value&key=value", UriKind.Absolute);
var pairs = uri.GetQueryString();
pairs.Count().ShouldBe(2);
pairs.ElementAt(0).Key.ShouldBe("key");
pairs.ElementAt(0).Value.ShouldBe("value");
pairs.ElementAt(1).Key.ShouldBe("key");
pairs.ElementAt(1).Value.ShouldBe("value");
}
示例8: ShouldHaveQueryStringItems
public void ShouldHaveQueryStringItems()
{
var uri = new Uri("/TestHarness.htm?xap=MyApp&class=MyClass&method=MyMethod", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.Items.ElementAt(0).Key.ShouldBe("xap");
model.Items.ElementAt(0).Value.ShouldBe("MyApp");
model.Items.ElementAt(1).Key.ShouldBe("class");
model.Items.ElementAt(1).Value.ShouldBe("MyClass");
model.Items.ElementAt(2).Key.ShouldBe("method");
model.Items.ElementAt(2).Value.ShouldBe("MyMethod");
}
示例9: ShouldAddXapModulesToRootModel
public void ShouldAddXapModulesToRootModel()
{
TestHarnessModel.ResetSingleton();
TestHarnessModel.Instance.Settings.Clear();
var testHarness = TestHarnessModel.Instance;
testHarness.Modules.Where(m => m.GetType() == typeof(ViewTestClassesAssemblyModule)).Count().ShouldBe(0);
var uri = new Uri("/TestHarness.htm?xap=One&xap=Two", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
var modules = testHarness.Modules.Where(m => m.GetType() == typeof (ViewTestClassesAssemblyModule)).Cast<ViewTestClassesAssemblyModule>();
modules.Count().ShouldBe(2);
modules.ElementAt(0).XapFileName.ShouldBe("One");
modules.ElementAt(1).XapFileName.ShouldBe("Two");
// ---
uri = new Uri("/TestHarness.htm?xap=One&xap=Three", UriKind.Relative);
model = new QueryString(uri.GetQueryString());
modules = testHarness.Modules.Where(m => m.GetType() == typeof(ViewTestClassesAssemblyModule)).Cast<ViewTestClassesAssemblyModule>();
modules.Count().ShouldBe(3);
modules.ElementAt(0).XapFileName.ShouldBe("One");
modules.ElementAt(1).XapFileName.ShouldBe("Two");
modules.ElementAt(2).XapFileName.ShouldBe("Three");
}
示例10: ShouldNotHaveTags
public void ShouldNotHaveTags()
{
var uri = new Uri("/TestHarness.htm?tag= ", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.Tags.Count().ShouldBe(0);
uri = new Uri("/TestHarness.htm", UriKind.Relative);
model = new QueryString(uri.GetQueryString());
model.Tags.Count().ShouldBe(0);
}
示例11: ShouldHaveThreeTags
public void ShouldHaveThreeTags()
{
var uri = new Uri("/TestHarness.htm?tag=one&tag= two &tag= three&", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.Tags.Count().ShouldBe(3);
model.Tags.ElementAt(0).ShouldBe("one");
model.Tags.ElementAt(1).ShouldBe("two");
model.Tags.ElementAt(2).ShouldBe("three");
}
示例12: ShouldReadUnitTestType
public void ShouldReadUnitTestType()
{
var uri = new Uri("/TestHarness.htm?testType=unitTest", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.TestType.ShouldBe(TestType.UnitTest);
}
示例13: ShouldHaveDefaultTestTypeWhenUnknownValueSpecified
public void ShouldHaveDefaultTestTypeWhenUnknownValueSpecified()
{
var uri = new Uri("/TestHarness.htm?testType=UNKNOWN", UriKind.Relative);
var model = new QueryString(uri.GetQueryString());
model.TestType.ShouldBe(TestType.ViewTest);
}
示例14: EncodeUri
/// <summary>
/// Encodes the URI to OpenWave image transformation URI.
/// </summary>
/// <param name="uri">The target URI.</param>
/// <returns>
/// Transformed URI instance.
/// </returns>
public Uri EncodeUri(Uri uri)
{
if (!IsSupportedUri(uri))
{
return uri;
}
var transformQuery = ImageTransformQuery.FromQueryString(uri.GetQueryString(), DefaultImageTransform);
var transformBuilder = ImageTransformationBuilderFactory.CreateBuilder();
transformBuilder.Width = transformQuery.Width;
transformBuilder.Height = transformQuery.Height;
transformBuilder.TransformType = transformQuery.Transform;
Url url = ImageTransformationService.GetTransformedImageUrl(Url.Parse(uri.ToString()), transformBuilder);
return new Uri(url.ToString(), UriKind.RelativeOrAbsolute);
}
示例15: IsSupportedUri
/// <summary>
/// Determines whether URL is supported to encode (contains image resizing request).
/// </summary>
/// <param name="uri">The target URI.</param>
/// <returns>
/// <c>true</c> if target URI is supported; otherwise, <c>false</c>
/// </returns>
public bool IsSupportedUri(Uri uri)
{
string fileExtension = (Path.GetExtension(uri.GetFileName()) ?? string.Empty).ToLower();
if (ValidImageExtensions.Contains(fileExtension))
{
var queryString = uri.GetQueryString();
// if some transformation requested.
if (!ImageTransformQuery.FromQueryString(queryString, DefaultImageTransform).IsEmpty)
{
return true;
}
}
return false;
}