private static string objectJSONValue(object o) { StringBuilder buffer = new StringBuilder(); if (o is List <object> ) { List <object> lst = (List <object>)o; buffer.Append("["); for (int i = 0; i < lst.Count; i++) { buffer.Append(objectJSONValue(lst[i])); if (i + 1 < lst.Count) { buffer.Append(","); } } buffer.Append("]"); } else if (o is Dictionary <object, object> ) { Dictionary <object, object> m = (Dictionary <object, object>)o; buffer.Append(getDictionaryToJson(m)); } else if (o is int || o is Double || o is double || o is Boolean || o is bool || o is long || o is float) { buffer.Append(o); } else if (o is string) { buffer.Append("\"").Append(o).Append("\""); } else { Dictionary <object, object> objMap = ParamInvokeUtil.getRequestParams(o, ""); buffer.Append(getDictionaryToJson(objMap)); } return(buffer.ToString()); }
public static String getExpireAuth(Dictionary <object, object> context, int expiresSecond, RequestInputModel Params) { Config Config = (Config)context[Constant.CONFIG_CONTEXT_KEY]; Dictionary <object, object> paramsQuery = ParamInvokeUtil.getRequestParams(Params, Constant.PARAM_TYPE_QUERY); Dictionary <object, object> paramsHeaders = ParamInvokeUtil.getRequestParams(Params, Constant.PARAM_TYPE_HEADER); paramsHeaders.Remove(Constant.HEADER_PARAM_KEY_DATE); paramsHeaders.Clear(); paramsHeaders.Add(Constant.HEADER_PARAM_KEY_EXPIRES, expiresSecond + ""); string method = (string)context[Constant.PARAM_KEY_REQUEST_METHOD]; string requestPath = Config.getHost() + Config.getUri(); string authSign = getSignature( Config.getAccessKey(), Config.getAccessSecret(), method, requestPath, paramsQuery, paramsHeaders); return(HttpUtility.UrlEncode(authSign, Encoding.GetEncoding(Constant.ENCODING_UTF8))); }