當前位置: 首頁>>代碼示例>>C#>>正文


C# Uri.GetQueryParameters方法代碼示例

本文整理匯總了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));
        }
開發者ID:xlongtang,項目名稱:nextra,代碼行數:7,代碼來源:Uri_ExtensionsBehavior.cs

示例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"));
        }
開發者ID:xlongtang,項目名稱:nextra,代碼行數:9,代碼來源:Uri_ExtensionsBehavior.cs

示例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(""));
        }
開發者ID:xlongtang,項目名稱:nextra,代碼行數:13,代碼來源:Uri_ExtensionsBehavior.cs

示例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);
        }
開發者ID:Coilz,項目名稱:BandWebsite,代碼行數:17,代碼來源:PhotoProcess.cs

示例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);
        }
開發者ID:Plasma,項目名稱:Ewk.SoundCloud,代碼行數:24,代碼來源:SoundCloud.cs


注:本文中的System.Uri.GetQueryParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。