當前位置: 首頁>>代碼示例>>C#>>正文


C# RestClient.ClearHandlers方法代碼示例

本文整理匯總了C#中RestSharp.RestClient.ClearHandlers方法的典型用法代碼示例。如果您正苦於以下問題:C# RestClient.ClearHandlers方法的具體用法?C# RestClient.ClearHandlers怎麽用?C# RestClient.ClearHandlers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RestSharp.RestClient的用法示例。


在下文中一共展示了RestClient.ClearHandlers方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Create

        /// <summary>
        /// Simply returns a new RestClient() object.
        /// </summary>
        public IRestClient Create(IConfiguration config)
        {
            string userName = config.Authorization.UserName;
            string password = config.Authorization.Password;

            string userAgent = config.UserAgent;

            if (String.IsNullOrWhiteSpace(userAgent))
                userAgent = String.Format("3Seventy SDK.NET {0}", m_version);

            // TODO: As of RestSharp 105.x you have to supply a base URL here!

            var rval = new RestClient
            {
                Authenticator = new HttpBasicAuthenticator(userName, password),
                UserAgent = userAgent,
                Timeout = (int)config.Timeout.TotalMilliseconds
            };

            rval.ClearHandlers();
            rval.AddHandler("application/json", new NewtonsoftSerializer());
            rval.AddHandler("text/json", new NewtonsoftSerializer());

            rval.AddHandler("application/xml", new XmlDeserializer());
            rval.AddHandler("text/xml", new XmlDeserializer());

            return rval;
        }
開發者ID:pankhuri3,項目名稱:vector370-dotnet,代碼行數:31,代碼來源:DefaultRestClientFactory.cs

示例2: buttonCrawl_Click

 private void buttonCrawl_Click(object sender, EventArgs e)
 {            
     var client = new RestClient(_protocol + "://" + _host);
     client.ClearHandlers();
     client.UserAgent = _userAgent;
     if (!string.IsNullOrEmpty(_cookie))
     {
         client.CookieContainer = ParseCookie(_cookie, _host);
     }
     buttonCrawl.Enabled = false;
     for (var n2 = _start2; n2 <= _end2; n2++)
     {
         for (var n1 = _start1; n1 <= _end1; n1++)
         {
             var n1S = n1.ToString("D" + _pad1);
             var n2S = n2.ToString("D" + _pad2);
             var request = new RestRequest(_resource.Replace("#1", n1S).Replace("#2", n2S));
             var path = _dir.Replace("#1", n1S).Replace("#2", n2S);
             client.DownloadData(request).SaveAs(path);
             if (_delay > 0)
             {
                 Thread.Sleep(_delay);
             }
         }
     }
     buttonCrawl.Enabled = true;
 }
開發者ID:DumpsterDoofus,項目名稱:SequentialUrlDownloader,代碼行數:27,代碼來源:Form1.cs

示例3: GetCustomerBillsOfLading

        public CustomerBillsOfLading GetCustomerBillsOfLading(UserDetails userDetails)
        {
            //check input methods here
            //user details are both not null
            //throw fault exception
            ValidationHelpers.ValidateUserDetails(userDetails);

            var AdvantumWebService = ConfigurationManager.AppSettings["AdvantumWS"];

            var httpRequestclient = new RestClient(AdvantumWebService);
            var webServiceMethodRequest = new RestRequest("GetCustomerBls.php", Method.GET);
            httpRequestclient.ClearHandlers();
            httpRequestclient.AddHandler("application/xml", new XmlDeserializer());

            webServiceMethodRequest.AddParameter("username", userDetails.UserName);
            webServiceMethodRequest.AddParameter("password", userDetails.PassWord);

            var httpResponse = httpRequestclient.Execute(webServiceMethodRequest);

            var systemResponse = new SystemResponse<CustomerBillsOfLading>();

            //this will throw fault exceptions if it failscd
            systemResponse = DeserializationHelpers.ProcessWebServiceResponse<CustomerBillsOfLading>(httpResponse);

            //otherwise results will be returned
            return systemResponse.Result;
        }
開發者ID:Kingston-Wharves,項目名稱:TestProjects,代碼行數:27,代碼來源:EpayServiceRest.cs

示例4: LoadData

        public void LoadData()
        {
            var client = new RestClient("http://api.nytimes.com");
            client.ClearHandlers();
            var request = new RestRequest("{a}/{b}/{c}/{d}/{e}/{f}");
            request.AddUrlSegment("a", "svc");
            request.AddUrlSegment("b", "mostpopular");
            request.AddUrlSegment("c", "v2");
            request.AddUrlSegment("d", "mostviewed");
            request.AddUrlSegment("e", "all-sections");
            request.AddUrlSegment("f", "1.json");

            request.AddParameter("api-key", "536306de3cfe2283df9c091afea40e82:9:67546031");
            request.RequestFormat = DataFormat.Json;

            try
            {
                var asyncHandle = client.ExecuteAsync(request, response =>
                {
                    if (response.ResponseStatus == ResponseStatus.Completed)
                    {
                        UpdateArticleList(response.Content);
                        MessageBox.Show(response.Content);
                    }
                    else
                        MessageBox.Show("Tidak dapat terhubung ke server");
                });
            }
            catch {
                MessageBox.Show("Eksekusi Gagal");

            }
        }
開發者ID:noormaulida,項目名稱:NewsPortal,代碼行數:33,代碼來源:MainPageController.cs

示例5: AuthenticationRequest

 public AuthenticationRequest(string url)
 {
     client = new RestClient(url);
     client.ClearHandlers();
     client.AddHandler("application/json", new JsonDeserializer());
     client.CookieContainer = RequestsHelper.GetCookieContainer();
 }
開發者ID:HackatonArGP,項目名稱:Guardianes,代碼行數:7,代碼來源:AuthenticationRequest.cs

示例6: GetBillOfLadingReferenceCharges

        public BillsOfLadingReferenceCharges GetBillOfLadingReferenceCharges(ICollection<BillOfLadingChargeRequest> chargeRequests)
        {
            var AdvantumWebService = ConfigurationManager.AppSettings["AdvantumWS"];

            var client = new RestClient(AdvantumWebService);
            var request = new RestRequest("getBlRefCharges.php", Method.GET);
            client.ClearHandlers();
            client.AddHandler("application/xml", new XmlDeserializer());

            string blReference = null;
            string storageTo = null;

            foreach (var item in chargeRequests)
            {
                blReference = string.IsNullOrEmpty(blReference) ? item.BLReferenceNumber.ToString() : blReference + "*" + item.BLReferenceNumber;
                storageTo = string.IsNullOrEmpty(storageTo) ? item.StorageToDate.ToString("yyyyMMdd") : storageTo + "*" + item.StorageToDate.ToString("yyyyMMdd");
            }

            request.AddParameter("blreference", blReference);
            request.AddParameter("storageto", storageTo);

            var httpResponse = client.Execute(request);

            var systemResponse = new SystemResponse<BillsOfLadingReferenceCharges>();

            //this will throw fault exceptions if it failscd
            systemResponse = DeserializationHelpers.ProcessWebServiceResponse<BillsOfLadingReferenceCharges>(httpResponse);

            //otherwise results will be returned as per usual
            return systemResponse.Result;
        }
開發者ID:Kingston-Wharves,項目名稱:TestProjects,代碼行數:31,代碼來源:EpayServiceRest.cs

示例7: NewsRequests

 public NewsRequests(string baseUrl)
 {
     client = new RestClient(baseUrl);
     //client.Re
     client.ClearHandlers();
     client.AddHandler("application/json", new JsonDeserializer());
 }
開發者ID:HackatonArGP,項目名稱:Guardianes,代碼行數:7,代碼來源:NewsRequests.cs

示例8: findPatient

        public static Patient findPatient(string firstName, string lastName, string birthDate, string streetAddress, string gender, string phoneNumber)
        {
            List<Tuple<string, string>> stringParams = generateParamsList(firstName, lastName, birthDate, streetAddress, gender, phoneNumber);

            var client = new RestClient("https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/");
            client.ClearHandlers();
            client.AddHandler("application/xml", new XmlDeserializer());
            client.AddHandler("text/xml", new XmlDeserializer());

            var request = new RestRequest("Patient");
            request.RequestFormat = DataFormat.Xml;
            foreach (Tuple<string, string> param in stringParams)
            {
                request.AddParameter(param.Item1, param.Item2);
            }

            IRestResponse response = client.Execute(request);
            var content = response.Content;

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);
            dynamic json = (dynamic) JsonConvert.DeserializeObject(jsonString);
            // if there are multiple users, pick one functionality goes here
            string id = json.Bundle.entry.link.url["@value"];
            id = id.Replace("https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/Patient/", "");
            json = json.Bundle.entry.resource.Patient;
            return createPatientFromJson(json, id);
        }
開發者ID:Maast3r,項目名稱:Epic-BoilerMake,代碼行數:29,代碼來源:Patient.cs

示例9: NewsRequests

        public NewsRequests(string baseUrl)
        {
            client = new RestClient(baseUrl);
            client.ClearHandlers();
            client.AddHandler("application/json", new JsonDeserializer());

            client.CookieContainer = RequestsHelper.GetCookieContainer();
        }
開發者ID:HackatonArGP,項目名稱:Guardianes,代碼行數:8,代碼來源:NewsRequests.cs

示例10: TMDbClient

        public TMDbClient(string apiKey)
        {
            this.apiKey = apiKey;

            client = new RestClient(BaseUrl);
            client.AddDefaultParameter("api_key", apiKey, ParameterType.QueryString);
            client.ClearHandlers();
            client.AddHandler("application/json", new JsonDeserializer());
        }
開發者ID:tobsa,項目名稱:TvShowManager,代碼行數:9,代碼來源:TMDbClient.cs

示例11: GetSuggestions

        //private const string BaseUrl = @"http://localhost/API/";

        public static void GetSuggestions(Action<List<String>> callback, string term)
        {
            var client = new RestClient(BaseUrl);
            client.ClearHandlers();
            client.AddHandler("application/json", new JsonDeserializer());

            var request = new RestRequest("autocomplete");
            request.AddParameter("term", term);
            client.ExecuteAsync<List<String>>(request, response => callback(response.Data));
        }
開發者ID:HackatonArGP,項目名稱:Guardianes,代碼行數:12,代碼來源:OpengeocoderRequests.cs

示例12: LoadClient

 private void LoadClient()
 {
     _restClient = new RestClient(DropNet.Resource.SecureLoginBaseUrl);
     _restClient.ClearHandlers();
     _restClient.AddHandler("*", new JsonDeserializer());
     //probly not needed...
     RequestCount = 0;
     DataCount = 0;
     _requestHelper = new RequestHelper(_version);
 }
開發者ID:possan,項目名稱:DropNet,代碼行數:10,代碼來源:Client.cs

示例13: BitClient

 /// <summary>
 /// Default Constructor for the BitClient
 /// </summary>
 /// <param name="apiKey">The Api Key to use for the BandsInTown Requests</param>
 public BitClient(string apiKey)
 {
     _apiKey = apiKey;
     _restClient = new RestClient(_baseUrl);
     _restClient.ClearHandlers();
     _restClient.AddHandler("application/xml", new XmlAttributeDeserializer());
     //probly not needed...
     RequestCount = 0;
     DataCount = 0;
 }
開發者ID:dkarzon,項目名稱:BitSharp,代碼行數:14,代碼來源:Client.cs

示例14: GetBasicClient

        private IRestClient GetBasicClient(string baseUrl, string userAgent)
        {
            var client = new RestClient(baseUrl);
            client.UserAgent = userAgent;

            // Harvest API is inconsistent in JSON responses so we'll stick to XML
            client.ClearHandlers();
            client.AddHandler("application/xml", new HarvestXmlDeserializer());
            client.AddHandler("text/xml", new HarvestXmlDeserializer());

            return client;
        }
開發者ID:fcbenoit,項目名稱:harvest.net,代碼行數:12,代碼來源:RestSharpFactory.cs

示例15: findPerscriptions

        public static List<Perscription> findPerscriptions(string patientId)
        {
            List<Perscription> perscriptions = new List<Perscription>();

            var client = new RestClient("https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/");
            client.ClearHandlers();
            client.AddHandler("application/xml", new XmlDeserializer());
            client.AddHandler("text/xml", new XmlDeserializer());

            var request = new RestRequest("MedicationPrescription");
            request.AddParameter("patient", patientId);
            request.AddParameter("status", "active");

            request.RequestFormat = DataFormat.Xml;

            IRestResponse response = client.Execute(request);
            var content = response.Content;
            if (content == "")
            {
                return perscriptions;
            }

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);
            dynamic json = JsonConvert.DeserializeObject(jsonString);

            json = json.Bundle.entry;
            if (json != null)
            {
                if (json.Count > 1)
                {
                    foreach (dynamic perscriptionJson in json)
                    {
                        string id = perscriptionJson.link.url["@value"];
                        id = id.Replace("https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/MedicationPrescription/", "");
                        Perscription perscription = getPerscriptionFromJson(perscriptionJson.resource.MedicationPrescription, id);
                        perscriptions.Add(perscription);
                    }
                }
                else
                {
                    string id = json.link.url["@value"];
                    id = id.Replace("https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/MedicationPrescription/", "");
                    Perscription perscription = getPerscriptionFromJson(json.resource.MedicationPrescription, id);
                    perscriptions.Add(perscription);
                }
            }
            return perscriptions;
        }
開發者ID:Maast3r,項目名稱:Epic-BoilerMake,代碼行數:50,代碼來源:Perscription.cs


注:本文中的RestSharp.RestClient.ClearHandlers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。