当前位置: 首页>>代码示例>>C#>>正文


C# Dictionary.ToQueryString方法代码示例

本文整理汇总了C#中Dictionary.ToQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.ToQueryString方法的具体用法?C# Dictionary.ToQueryString怎么用?C# Dictionary.ToQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary.ToQueryString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSuggestSimilarDocumentsAsync

        public async Task<IEnumerable<Models.Products.ProductSuggestItemOutputModel>> GetSuggestSimilarDocumentsAsync(int id, string offerType = null, string domainLanguage = "fr", int take = 3)
        {
            using (var dclient = this.CreateClient())
            {
                var client = dclient.Client;
                var parameters = new Dictionary<string, string>();
                var dico = new Dictionary<string, string>(){
                { "domainLanguage", domainLanguage },
                { "take", take.ToString() },
                { "offerType", offerType }
            };

                var queryString = dico.ToQueryString();
                var url = "api/v2/products/{id}/suggests/similar".Replace("{id}", id.ToString());
                if (!string.IsNullOrEmpty(queryString))
                    url = url + "?" + queryString;
                var response = await client.GetAsync(this.GetUri(url)).ConfigureAwait(false);

                await this.HandleResponseAsync(response).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                    return (await this.GetObjectAsync<IEnumerable<Models.Products.ProductSuggestItemOutputModel>>(response.Content).ConfigureAwait(false));
                return Enumerable.Empty<Models.Products.ProductSuggestItemOutputModel>();
            }
        }
开发者ID:Youscribe,项目名称:YouscribeNet,代码行数:25,代码来源:ProductSuggestRequest.cs

示例2: ToString

 public override string ToString()
 {
     Dictionary<string, string> parameters = new Dictionary<string, string>();
     if (Lat.HasValue && Lon.HasValue)
     {
         parameters.Add("cp", string.Format("{0}~{1}", Lat.Value, Lon.Value));
     }
     if (Zoom.HasValue)
     {
         parameters.Add("lvl", Zoom.Value.ToString());
     }
     if (!String.IsNullOrWhiteSpace(Query))
     {
         parameters.Add("q", Query);
     }
     if (!String.IsNullOrWhiteSpace(Where))
     {
         parameters.Add("where", Where);
     }
     if (TrafficOn.HasValue)
     {
         parameters.Add("trfc", TrafficOn.Value ? "1" : "0");
     }
     if (RoadView.HasValue)
     {
         parameters.Add("sty", RoadView.Value ? "r" : "a");
     }
     return parameters.ToQueryString("bingmaps://dreamteam-mobile.com/");
 }
开发者ID:abettadapur,项目名称:LastFMEvents,代码行数:29,代码来源:MapsHelper.cs

示例3: ToQueryString

 public void ToQueryString()
 {
     var Collection = new Dictionary<string, string>();
     Collection.Add("A", "1");
     Collection.Add("B", "2");
     Assert.Equal("?A=1&B=2", Collection.ToQueryString());
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:7,代码来源:DictionaryExtensions.cs

示例4: AuthASync

        public async Task<RootAuth> AuthASync(string login, string password)
        {
            var postData = new Dictionary<string, string>();

            postData.Add("login", login);

            var md5Password = MD5CryptoServiceProvider.GetMd5String(password);

            postData.Add("password", md5Password);

            var options = "?" + postData.ToQueryString();

            RootAuth response;

            try
            {
                response = await Post<RootAuth>(AuthUrl + options, null);

                ValidateResponse(response);
            }
            catch (ConnectionException ex)
            {
                if (!string.IsNullOrEmpty(ex.ResponseContent))
                    ValidateResponse(ex.ResponseContent);

                throw;
            }
            
            return response;
        }
开发者ID:fabmoll,项目名称:BetaSeries.API,代码行数:30,代码来源:MemberService.cs

示例5: GetEpisodePictureASync

        public async Task<byte[]> GetEpisodePictureASync(int episodeId, int width, int height)
        {
            var postData = new Dictionary<string, string>();

            postData.Add("id", episodeId);

            if (width != 0)
                postData.Add("width", width);

            if (height != 0)
                postData.Add("height", height);

            postData.Add("picked", "show");

            var options = "?" + postData.ToQueryString();

            var response = await Get(EpisodeUrl + options);

            if (response.StatusCode == HttpStatusCode.NotFound)
                return null;

            var stream = await response.Content.ReadAsBufferAsync();

            var byteArray = stream.ToArray();

            return byteArray.Length == 0 ? null : byteArray;
        }
开发者ID:fabmoll,项目名称:BetaSeries.API,代码行数:27,代码来源:PictureService.cs

示例6: ToQueryStringOneValue

        public void ToQueryStringOneValue()
        {
            var dict = new Dictionary<string, string>();
            dict["foo"] = "bar";

            Assert.AreEqual("?foo=bar",
                             dict.ToQueryString());
        }
开发者ID:romansharin,项目名称:gengo-dotnet,代码行数:8,代码来源:ExtensionsTests.cs

示例7: ToQueryStringUnsafeValues

        public void ToQueryStringUnsafeValues()
        {
            var dict = new Dictionary<string, string>();
            dict["foo"] = "#?&%=";

            Assert.AreEqual("?foo=%23%3F%26%25%3D",
                             dict.ToQueryString());
        }
开发者ID:romansharin,项目名称:gengo-dotnet,代码行数:8,代码来源:ExtensionsTests.cs

示例8: PostBytes

        /// <summary>
        /// transform a dictionary into the query string that is translated in byte array then
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        public static byte[] PostBytes(Dictionary<string, string> items)
        {
            if (items == null || !items.Any())
                return null;

            var bytes = Encoding.UTF8.GetBytes(items.ToQueryString());

            return bytes.Any() ? bytes : null;
        }
开发者ID:monnster,项目名称:yandex-money-sdk-net,代码行数:14,代码来源:Misc.cs

示例9: ToQueryStringTwoValues

        public void ToQueryStringTwoValues()
        {
            var dict = new Dictionary<string, string>();
            dict["foo"] = "bar";
            dict["ba"] = "zinga";

            Assert.AreEqual("?foo=bar&ba=zinga",
                             dict.ToQueryString());
        }
开发者ID:romansharin,项目名称:gengo-dotnet,代码行数:9,代码来源:ExtensionsTests.cs

示例10: should_convert_string_dictionary_to_query_string

        public void should_convert_string_dictionary_to_query_string()
        {
            var values = new Dictionary<string, string> {
                {"key1", "value1"},
                {"key2", "value2"}
            };

            values.ToQueryString().Should().Be("key1=value1&key2=value2");
        }
开发者ID:Core4Tek,项目名称:Crux.Common,代码行数:9,代码来源:QueryStringExtensionsTester.cs

示例11: should_encode_values

        public void should_encode_values()
        {
            var values = new Dictionary<string, string> {
                {"name", "John Smith"},
                {"email", "[email protected]"}
            };

            values.ToQueryString(encode: true)
                .Should().Be("name=John+Smith&email=email%40website.com");
        }
开发者ID:Core4Tek,项目名称:Crux.Common,代码行数:10,代码来源:QueryStringExtensionsTester.cs

示例12: should_override_default_delimiters_when_writing

        public void should_override_default_delimiters_when_writing()
        {
            var values = new Dictionary<string, string> {
                {"key1", "value1"},
                {"key2", "value2"}
            };

            values.ToQueryString(paramDelimiter: ' ', valueDelimiter: '@')
                .Should().Be("[email protected] [email protected]");
        }
开发者ID:Core4Tek,项目名称:Crux.Common,代码行数:10,代码来源:QueryStringExtensionsTester.cs

示例13: InitContent

        public static void InitContent(dynamic viewBag, string nameSpace, string page, Dictionary<string, string> dimensions)
        {
            var repository = new ContentRepository(
                new Uri(System.Configuration.ConfigurationManager.AppSettings["NeuCMSServiceURL"])
                );

            var content = repository.GetViewContents(nameSpace,page, dimensions.ToQueryString()).ToList();

            dynamic neuCMSContent = new NeuCMSContent(content);
            viewBag.NeuContent = neuCMSContent;
        }
开发者ID:rbell,项目名称:NeuCMS,代码行数:11,代码来源:ContentManger.cs

示例14: GetObjectUrl

        public static string GetObjectUrl(string storageUrl, string containerId, string objectId, Dictionary<string, string> queryParams = null)
        {
            var url = storageUrl + "/" + containerId.Encode() + "/" + objectId.Encode();

            if (queryParams != null)
            {
                url += queryParams.ToQueryString();
            }

            return url;
        }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:11,代码来源:SwiftUrlBuilder.cs

示例15: GetAccountUrl

        public static string GetAccountUrl(string storageUrl, Dictionary<string, string> queryParams = null)
        {
            var url = storageUrl;

            if (queryParams != null)
            {
                url += queryParams.ToQueryString();
            }

            return url;
        }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:11,代码来源:SwiftUrlBuilder.cs


注:本文中的Dictionary.ToQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。