コード例 #1
0
 public static Task <JSONDataMap> GetValueMapAsync(Uri uri, RequestParams request)
 {
     return(GetStringAsync(uri, request)
            .ContinueWith((antecedent) =>
     {
         var response = antecedent.Result;
         return response.IsNotNullOrWhiteSpace() ? JSONDataMap.FromURLEncodedString(response) : null;
     }));
 }
コード例 #2
0
        public void JSONDataMapFromURLEncoded_KeyEmptyEqNormal()
        {
            var dict = JSONDataMap.FromURLEncodedString("a=&b&&=&=14&c=3459");

            Assert.AreEqual(3, dict.Count);
            Assert.AreEqual(string.Empty, dict["a"]);
            Assert.AreEqual(null, dict["b"]);
            Assert.AreEqual("3459", dict["c"]);
        }
コード例 #3
0
        public static JSONDataMap GetValueMap(Uri uri, IWebClientCaller caller,
                                              HTTPRequestMethod method = HTTPRequestMethod.GET,
                                              IDictionary <string, string> queryParameters = null,
                                              IDictionary <string, string> bodyParameters  = null,
                                              IDictionary <string, string> headers         = null)
        {
            string responseStr = GetString(uri, caller, method, queryParameters: queryParameters, bodyParameters: bodyParameters, headers: headers);
            var    dict        = JSONDataMap.FromURLEncodedString(responseStr);

            return(dict);
        }
コード例 #4
0
        public void JSONDataMapFromURLEncoded_Esc()
        {
            string[] strs = { " ", "!", "=", "&", "\"zele/m\\h()an\"" };

            foreach (var str in strs)
            {
                var query = "a=" + Uri.EscapeDataString(str);

                var dict = JSONDataMap.FromURLEncodedString(query);

                Aver.AreEqual(1, dict.Count);
                Aver.AreObjectsEqual(str, dict["a"]);
            }
        }
コード例 #5
0
ファイル: Facebook.cs プロジェクト: itadapter/nfx-1
        public static JSONDataMap DecodeState(string state)
        {
            try
            {
                var str = state.Replace('_', '/').Replace('-', '+');
                switch (state.Length % 4)
                {
                case 2: str += "=="; break;

                case 3: str += "="; break;
                }
                var url = Encoding.UTF8.GetString(Convert.FromBase64String(str));
                return(JSONDataMap.FromURLEncodedString(url));
            }
            catch (Exception)
            {
                return(new JSONDataMap());
            }
        }
コード例 #6
0
        public void JSONDataMapFromURLEncoded_WOAmpVal()
        {
            var dict = JSONDataMap.FromURLEncodedString("=1");

            Aver.AreEqual(0, dict.Count);
        }
コード例 #7
0
        public static JSONDataMap GetValueMap(Uri uri, RequestParams request)
        {
            string response = GetString(uri, request);

            return(response.IsNotNullOrWhiteSpace() ? JSONDataMap.FromURLEncodedString(response) : null);
        }