示例#1
0
        private static string GetBaseString(IEnumerable <KeyValuePair <string, object> > paramList, bool urlEncode = false, BaseStringPreprocessingDelegate baseStringPreprocessing = null)
        {
            var sb = new StringBuilder();

            paramList.OrderBy(p => p.Key).Select(p =>
            {
                var k = urlEncode ? CodecUtil.UrlEncode(p.Key) : p.Key;
                var v = urlEncode ? CodecUtil.UrlEncode(p.Value.ToString()) : p.Value;
                return($"{k}={v}");
            }).ToList().ForEach(p =>
            {
                if (sb.Length != 0)
                {
                    sb.Append("&");
                }
                sb.Append(p);
            });
            var str = sb.ToString();

            return(baseStringPreprocessing != null?baseStringPreprocessing(str) : str);
        }