コード例 #1
0
 protected void ExecuteGet(Dictionary <string, object> parameterDict,
                           EventHandler <ServiceEventArgs> callbackFunc,
                           Dictionary <string, object> fileDict   = null,
                           Dictionary <string, string> headerDict = null,
                           object entity = null)
 {
     Task task = Task.Factory.StartNew(() =>
     {
         bool iss       = false;
         string content = "";
         try
         {
             content = RestSharpHelper.HttpGet(this.m_Url, this.m_Resource, parameterDict, out iss, fileDict, headerDict, entity);
             if (callbackFunc != null)
             {
                 callbackFunc(this, new ServiceEventArgs(content, iss));
             }
         }
         catch (Exception ex)
         {
             if (callbackFunc != null)
             {
                 callbackFunc(this, new ServiceEventArgs(content, iss)
                 {
                     Message = ex.Message + "\r\n" + ex.StackTrace
                 });
             }
         }
     });
 }
コード例 #2
0
        public void HttpGetTest()
        {
            string s;
            bool   b = false;

            //测试用例1
            s = RestSharpHelper.HttpGet((string)null, (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(false, b);
            //测试用例2
            s = RestSharpHelper.HttpGet("", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(false, b);
            //测试用例3
            s = RestSharpHelper.HttpGet(":xn--%\0\0", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(false, b);
            //测试用例4
            s = RestSharpHelper.HttpGet("/\\/", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(false, b);
            //测试用例5
            s = RestSharpHelper.HttpGet("\0\0:", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(false, b);
            //测试用例6
            s = RestSharpHelper.HttpGet("x0: ", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(true, b);
            //测试用例7
            s = RestSharpHelper.HttpGet("xA:‏", (string)null, (Dictionary <string, object>)null,
                                        out b, (Dictionary <string, object>)null,
                                        (Dictionary <string, string>)null, (object)null);
            Assert.AreEqual <bool>(true, b);
        }