本文整理匯總了C#中System.Uri.GetQueryParameters方法的典型用法代碼示例。如果您正苦於以下問題:C# Uri.GetQueryParameters方法的具體用法?C# Uri.GetQueryParameters怎麽用?C# Uri.GetQueryParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Uri
的用法示例。
在下文中一共展示了Uri.GetQueryParameters方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetQueryParameters_ShouldReturnEmptyDictionaryForNoParameters
public void GetQueryParameters_ShouldReturnEmptyDictionaryForNoParameters()
{
var uri = new Uri("http://www.foo.bar/index.htm");
var result = uri.GetQueryParameters();
Assert.That(result.Count(), Is.EqualTo(0));
}
示例2: GetQueryParameters_ShouldReturnOneElementDictionaryForSingleParameter
public void GetQueryParameters_ShouldReturnOneElementDictionaryForSingleParameter()
{
var uri = new Uri("http://www.foo.bar/index.htm?foo=bar");
var result = uri.GetQueryParameters();
Assert.That(result.Count(), Is.EqualTo(1));
Assert.That(result.First().Key, Is.EqualTo("foo"));
Assert.That(result.First().Value, Is.EqualTo("bar"));
}
示例3: GetQueryParameters_ShouldHandleBrokenParameter
public void GetQueryParameters_ShouldHandleBrokenParameter()
{
var uri = new Uri("http://www.foo.bar/index.htm?foo=bar&bar=foo&broken");
var result = uri.GetQueryParameters();
Assert.That(result.Count(), Is.EqualTo(3));
Assert.That(result.First().Key, Is.EqualTo("foo"));
Assert.That(result.First().Value, Is.EqualTo("bar"));
Assert.That(result.ElementAt(1).Key, Is.EqualTo("bar"));
Assert.That(result.ElementAt(1).Value, Is.EqualTo("foo"));
Assert.That(result.Last().Key, Is.EqualTo("broken"));
Assert.That(result.Last().Value, Is.EqualTo(""));
}
示例4: Authorize
public void Authorize(Uri verificationUri)
{
if (verificationUri == null) throw new ArgumentNullException("verificationUri");
var verifier = verificationUri.GetQueryParameters()["oauth_verifier"];
var entity = GetAdapterSettings();
if (string.IsNullOrEmpty(verifier) || entity.OAuthRequestToken == null)
{
throw new AuthorizationException();
}
var accessToken = PhotoAdapter.GetOAuthAccessToken(entity.OAuthRequestToken, verifier);
entity.OAuthRequestToken = null;
entity.OAuthAccessToken = accessToken;
UpdateAdapterSettings(entity);
}
示例5: RequestOAuthToken
/// <summary>
/// Requests an <see cref="OAuth2Token"/> using the <see cref="Uri"/> that was requested after the Authorization by the user.
/// </summary>
/// <param name="responseUri">The complete <see cref="Uri"/> of the request after Authorization.</param>
/// <param name="clientSecret">The api secret of the app.</param>
/// <returns>An <see cref="OAuth2Token"/> that can be used to access protected resources.</returns>
public OAuth2Token RequestOAuthToken(Uri responseUri, string clientSecret)
{
if (responseUri == null) throw new ArgumentNullException("responseUri");
if (_soundCloudClient.RedirectUri == null)
{
var baseUrl = new Uri(responseUri.GetLeftPart(UriPartial.Authority));
_soundCloudClient.RedirectUri = new Uri(baseUrl, responseUri.AbsolutePath);
}
var queryPairs = responseUri.GetQueryParameters();
if (queryPairs.ContainsKey("error"))
{
throw new ArgumentException(string.Format("Error: {0}, Description: {1}", queryPairs["error"], queryPairs["error_description"]));
}
return _soundCloudClient.OAuthToken = _soundCloudClient.RequestOAuthToken(queryPairs["code"], clientSecret);
}