Ejemplo n.º 1
0
        /// <summary>
        /// 将参数转换为 StringContent
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public static StringContent GetStringContent(this BaseMethod method)
        {
            var dic = method.GetParams();
            var str = string.Join("&", dic.Select(s => string.Format("{0}={1}", s.Key, s.Value)));

            return(new StringContent(str));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将参数编进URL
        /// </summary>
        /// <param name="method"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string BuildUrl(this BaseMethod method, string url)
        {
            var dic = method.GetParams();

            foreach (var kv in dic)
            {
                url = url.SetUrlKeyValue(kv.Key, WebUtility.UrlEncode(kv.Value.ToString()));
            }

            return(url);
        }