public IDictionary <string, string> GetParameters() { ParamDictionary parameters = new ParamDictionary(); parameters.Add("biz_content", this.Biz_Content); return(parameters); }
public T Execute <T>(IRequest <T> request, string session, string appAuthToken) where T : IResponse { // 构造请求参数 ParamDictionary requestParams = buildRequestParams(request, session, appAuthToken); // 字典排序 IDictionary <string, string> sortedParams = new SortedDictionary <string, string>(requestParams); ParamDictionary sortedDic = new ParamDictionary(sortedParams); // 参数签名 string charset = string.IsNullOrEmpty(this.charset) ? "utf-8" : this.charset; //string signResult = Signature.RSASign(sortedDic, privateKeyPem, charset, this.keyFromFile, this.signType); //// 添加签名结果参数 //sortedDic.Add(SIGN, signResult); // 参数拼接 string signedResult = WebUtils.BuildQuery(sortedDic, charset); var txtParams = sortedDic; // 是否需要上传文件 string body; string requestBody = null; string url = ""; // this.serverUrl + "?" + CHARSET + "=" + this.charset; url = GetFullUrl(this.serverUrl, request.GetApiName()); // + "?" + CHARSET + "=" + this.charset; if (request is IUploadRequest <T> ) { IUploadRequest <T> uRequest = (IUploadRequest <T>)request; IDictionary <string, FileItem> fileParams = SdkUtils.CleanupDictionary(uRequest.GetFileParameters()); body = webUtils.DoPost(url, txtParams, fileParams, this.charset, out requestBody); } else { body = webUtils.DoPost(url, txtParams, this.charset, out requestBody); } T rsp = null; IParser <T> parser = null; if ("xml".Equals(format)) { parser = new XmlParser <T>(); rsp = parser.Parse(body, charset); } else { parser = new JsonParser <T>(); rsp = parser.Parse(body, charset); } ResponseParseItem item = parseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset); rsp = parser.Parse(item.realContent, charset); rsp.RequestBody = requestBody; CheckResponseSign(request, item.respContent, rsp.IsError, parser, this.publicKey, this.charset, signType, this.keyFromFile); return(rsp); }
public Task <IDictionary <string, string> > ReadFormAsync() { if (!HasFormData && !HasParseableData) { return(TaskHelpers.FromResult(ParamDictionary.Parse(""))); } var form = Environment.Get <IDictionary <string, string> >("Gate.Request.Form"); var thisInput = Body; var lastInput = Environment.Get <object>("Gate.Request.Form#input"); if (form != null && ReferenceEquals(thisInput, lastInput)) { return(TaskHelpers.FromResult(form)); } Request thisRequest = this; return(ReadTextAsync().Then(text => { form = ParamDictionary.Parse(text); thisRequest.Environment.Set("Gate.Request.Form#input", thisInput); thisRequest.Environment.Set("Gate.Request.Form", form); return form; })); }
public void RouteValue(RouteValueDictionary routeValue) { if (routeValue != null) { routeValue.ToList().ForEach(item => { ParamDictionary.Add(item.Key, item.Value.ToString()); }); } }
public ParamDictionary getParamDictionary() { global::System.IntPtr cPtr = OgrePINVOKE.SkeletonPtr_getParamDictionary__SWIG_0(swigCPtr); ParamDictionary ret = (cPtr == global::System.IntPtr.Zero) ? null : new ParamDictionary(cPtr, false); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public string this[string key] { get { if (!ParamDictionary.ContainsKey(key)) { return(string.Empty); } return(ParamDictionary[key]); } }
private ParamDictionary SerializeBizModel <T>(ParamDictionary requestParams, IRequest <T> request) where T : IResponse { ParamDictionary result = requestParams; Boolean isBizContentEmpty = !requestParams.ContainsKey(BIZ_CONTENT) || string.IsNullOrEmpty(requestParams[BIZ_CONTENT]); if (isBizContentEmpty && request.GetBizModel() != null) { IObject bizModel = request.GetBizModel(); string content = Newtonsoft.Json.JsonConvert.SerializeObject(bizModel); result.Add(BIZ_CONTENT, content); } return(result); }
private ParamDictionary buildRequestParams <T>(IRequest <T> request, string accessToken, string appAuthToken) where T : IResponse { // 默认参数 ParamDictionary oriParams = new ParamDictionary(request.GetParameters()); // 序列化BizModel ParamDictionary result = SerializeBizModel(oriParams, request); // 获取参数 string charset = string.IsNullOrEmpty(this.charset) ? "utf-8" : this.charset; string version = string.IsNullOrEmpty(request.Version) ? this.Version : request.Version; // 添加协议级请求参数,为空的参数后面会自动过滤,这里不做处理。 result.Add(METHOD, request.GetApiName()); result.Add(VERSION, version); result.Add(APP_ID, appId); result.Add(FORMAT, format); result.Add(TIMESTAMP, DateTime.Now); result.Add(ACCESS_TOKEN, accessToken); result.Add(SIGN_TYPE, signType); result.Add(CHARSET, charset); result.Add(APP_AUTH_TOKEN, appAuthToken); if (request.GetNeedEncrypt()) { if (string.IsNullOrEmpty(result[BIZ_CONTENT])) { throw new ApiException("api request Fail ! The reason: encrypt request is not supported!"); } if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType)) { throw new ApiException("encryptType or encryptKey must not null!"); } if (!"AES".Equals(this.encyptType)) { throw new ApiException("api only support Aes!"); } string encryptContent = EncryptUtils.AesEncrypt(this.encyptKey, result[BIZ_CONTENT], this.charset); result.Remove(BIZ_CONTENT); result.Add(BIZ_CONTENT, encryptContent); result.Add(ENCRYPT_TYPE, this.encyptType); } return(result); }
private IEnumerable <KeyValuePair <string, string> > ReadForm() { if (!HasFormData && !HasParseableData) { return(Enumerable.Empty <KeyValuePair <string, string> >()); } var body = RequestBody; if (body.CanSeek) { body.Seek(0, SeekOrigin.Begin); } var text = new StreamReader(body).ReadToEnd(); return(ParamDictionary.ParseToEnumerable(text)); }
public IDictionary <string, string> ReadForm() { if (!HasFormData && !HasParseableData) { return(ParamDictionary.Parse("")); } var form = Environment.Get <IDictionary <string, string> >("Gate.Request.Form"); var thisInput = Body; var lastInput = Environment.Get <object>("Gate.Request.Form#input"); if (form != null && ReferenceEquals(thisInput, lastInput)) { return(form); } var text = ReadText(); form = ParamDictionary.Parse(text); Environment.Set("Gate.Request.Form#input", thisInput); Environment.Set("Gate.Request.Form", form); return(form); }
public ROSMasterHandler() { reg_manager = new RegistrationManager(); publishers = reg_manager.publishers; subscribers = reg_manager.subscribers; services = reg_manager.services; param_subscribers = reg_manager.param_subscribers; topic_types = new Dictionary<String, String>(); param_server = new rosmaster.ParamDictionary(reg_manager); }
public static object ToParamObject(this ParamDictionary parameters) { return(parameters.Any() ? AnonymousBuilder.CreateInstance(parameters.Values.Select(i => PropertyDef.New(i.Name, i.Value)).ToArray()) : null); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ParamDictionary obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }