public T Post <T, Q>(string body, Q queryModel = default(Q)) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); var url = String.Format("{0}{1}", Url, s ?? ""); return(Post <T>(url, body)); }
/// <summary> /// POST方式获取实体模型 /// </summary> /// <typeparam name="T">返回实体模型类型</typeparam> /// <typeparam name="Q">请求参数实体模型类型</typeparam> /// <param name="url">url地址</param> /// <param name="queryModel">请求参数模型</param> /// <param name="cc">为System.Net.CookieCollection对象的集合提供容器</param> /// <param name="refer">获取和设置http标头值</param> /// <returns>返回实体模型</returns> public static T Post <T, Q>(string url, Q queryModel = default(Q), CookieContainer cc = null, string refer = null) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); return(Post <T>(url, s, cc, refer)); }
/// <summary> /// 以GET方式请求,返回响应的字符串 /// </summary> /// <typeparam name="Q">请求参数模型类型</typeparam> /// <param name="url">url地址</param> /// <param name="queryModel">请求参数模型</param> /// <param name="cc">为System.Net.CookieCollection对象的集合提供容器</param> /// <param name="refer">获取和设置http标头值</param> /// <returns>返回响应字符串</returns> public static string GetString <Q>(string url, Q queryModel = default(Q), CookieContainer cc = null, string refer = null) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); return(new StreamReader(Get(url, s, cc, refer)).ReadToEnd()); }
/// <summary> /// GET 方式获取响应流 /// </summary> /// <typeparam name="T">返回实体对象</typeparam> /// <typeparam name="Q">请求的参数实体对象类型</typeparam> /// <param name="url">url地址</param> /// <param name="queryModel">请求的参数实体对象</param> /// <param name="cc">为System.Net.CookieCollection对象的集合提供容器</param> /// <param name="refer">获取和设置http标头值</param> /// <returns>返回响应流</returns> public static T Get <T, Q>(string url, Q queryModel = default(Q), CookieContainer cc = null, string refer = null) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); var json = new StreamReader(Get(url, s, cc, refer), Encoding).ReadToEnd(); return(Deserialize <T>(json)); }
public string Upload <Q>(string filePath, Q queryModel = default(Q)) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); var url = String.Format("{0}?{1}", Url, s ?? ""); var data = new WebClient().UploadFile(url, "POST", filePath); return(Encoding.GetString(data)); }
public T Get <T, Q>(Q queryModel) { var s = FormatQueryParaProvider.FormatQueryParaMap(queryModel, true, true); return(Deserialize <T>(GetString(s))); }