当前位置: 首页>>代码示例>>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;未经允许,请勿转载。