当前位置: 首页>>代码示例>>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;未经允许,请勿转载。