static void Main(string[] args)
        {
            Console.WriteLine("Fetching the list of RestSharp releases and their publish dates.");
            Console.WriteLine();

            //These are the five ways to consume RESTful APIs described in the blog post
            IRequestHandler httpWebRequestHandler = new HttpWebRequestHandler();
            IRequestHandler webClientRequestHandler = new WebClientRequestHandler();
            IRequestHandler httpClientRequestHandler = new HttpClientRequestHandler();
            IRequestHandler restSharpRequestHandler = new RestSharpRequestHandler();
            IRequestHandler serviceStackRequestHandler = new ServiceStackRequestHandler();

            //to support github's depreciation of older cryptographic standards
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //Currently HttpWebRequest is used to get the RestSharp releases
            //Replace the httpWebRequestHandler variable with one of the above to test out different libraries
            //Results should be the same
            var releases = GetReleases(httpWebRequestHandler);

            //List out the retreived releases
            foreach (var jToken in releases.Children())
            {
                var release = (JObject) jToken;
                Console.WriteLine("Release: {0}", release.GetValue("name"));
                Console.WriteLine("Published: {0}", DateTime.Parse(release.GetValue("published_at").ToString()));
                Console.WriteLine();
            }

            Console.ReadLine();
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();

            IRequestHandler httpWebRequestHandler      = new HttpWebRequestHandler();
            IRequestHandler webClientRequestHandler    = new WebClientRequestHandler();
            IRequestHandler httpClientRequestHandler   = new HttpClientRequestHandler();
            IRequestHandler restSharpRequestHandler    = new RestSharpRequestHandler();
            IRequestHandler serviceStackRequestHandler = new ServiceStackRequestHandler();
            IRequestHandler flurlRequestHandler        = new FlurlRequestHandler();
            IRequestHandler dalSoftRequestHandler      = new DalSoftRequestHandler();


            var response = GetReleases(httpWebRequestHandler);

            var githubReleases = JsonConvert.DeserializeObject <List <GitHubRelease> >(response);



            foreach (var release in githubReleases)

            {
                CustomerEmaillbl.Text = customerCombobox.Text;


                customerCombobox.Items.Add(release);
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Fetching the list of RestSharp releases and their publish dates.");
            Console.WriteLine();

            //These are the six ways to consume RESTful APIs described in the blog post
            IRequestHandler httpWebRequestHandler      = new HttpWebRequestHandler();
            IRequestHandler webClientRequestHandler    = new WebClientRequestHandler();
            IRequestHandler httpClientRequestHandler   = new HttpClientRequestHandler();
            IRequestHandler restSharpRequestHandler    = new RestSharpRequestHandler();
            IRequestHandler serviceStackRequestHandler = new ServiceStackRequestHandler();
            IRequestHandler flurlRequestHandler        = new FlurlRequestHandler();

            //to support github's depreciation of older cryptographic standards
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //Currently HttpWebRequest is used to get the RestSharp releases
            //Replace the httpWebRequestHandler variable with one of the above to test out different libraries
            //Results should be the same
            var response = GetReleases(httpWebRequestHandler);

            var githubReleases = JsonConvert.DeserializeObject <List <GitHubRelease> >(response);

            foreach (var release in githubReleases)
            {
                Console.WriteLine("Release: {0}", release.Name);
                Console.WriteLine("Published: {0}", DateTime.Parse(release.PublishedAt));
                Console.WriteLine();
            }

            Console.ReadLine();
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Fetching the list of RestSharp releases and their publish dates.");
            Console.WriteLine();

            //These are the five ways to consume RESTful APIs described in the blog post
            IRequestHandler httpWebRequestHandler      = new HttpWebRequestHandler();
            IRequestHandler webClientRequestHandler    = new WebClientRequestHandler();
            IRequestHandler httpClientRequestHandler   = new HttpClientRequestHandler();
            IRequestHandler restSharpRequestHandler    = new RestSharpRequestHandler();
            IRequestHandler serviceStackRequestHandler = new ServiceStackRequestHandler();

            //Currently HttpWebRequest is used to get the RestSharp releases
            //Replace the httpWebRequestHandler variable with one of the above to test out different libraries
            //Results should be the same
            var releases = GetReleases(serviceStackRequestHandler);

            //List out the retreived releases
            foreach (JObject release in releases.Children())
            {
                Console.WriteLine("Release: {0}", release.GetValue("name"));
                Console.WriteLine("Published: {0}", DateTime.Parse(release.GetValue("published_at").ToString()));
                Console.WriteLine();
            }

            Console.ReadLine();
        }
示例#5
0
 /// <summary>
 ///     提供相应的处理器来对该 HTTP 请求进行处理,例如添加凭证,Cookies,Header。
 /// </summary>
 /// <param name="handler"></param>
 /// <returns></returns>
 public HttpRequest HandleRequest(HttpWebRequestHandler handler)
 {
     if (State != HttpRequestState.NothingSpecial)
     {
         throw new InvalidOperationException("不能对传输中的请求进行修改,如果请求已经结束,请使用 HttpRequest.RebuildRequest 方法重构请求。");
     }
     handler(Request);
     return(this);
 }
示例#6
0
        public HttpSolrServer(string url, IContentSerializerFactory contentSerializerFactory = null, ICacheHandler cacheHandler = null, bool ignoreStatusCheck = false)
        {
            //Argument Validation
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url");
            }
            if (url.EndsWith("/"))
            {
                url = url.TrimEnd('/');
            }
            Uri solrUri;

            if (!Uri.TryCreate(url, UriKind.Absolute, out solrUri))
            {
                throw new ArgumentException("the URL is invalid", "url");
            }
            RequestHandler = new HttpWebRequestHandler();
            if (!RequestHandler.IsUriSupported(solrUri))
            {
                throw new ArgumentException("the URL is invalid", "url");
            }

            //Initialization
            RecheckInterval   = new TimeSpan(0, 1, 0);
            baseUriBuilder    = new SolrUriBuilder(solrUri);
            SerializerFactory = contentSerializerFactory ?? new ContentSerializerFactory();
            DataMapping       = new DataMappingCollection();
            Cache             = cacheHandler ?? null;
            IsReady           = true;
            if (ignoreStatusCheck)
            {
                _isOnline = true;
            }
            else
            {
                CheckStatus(true);
            }
        }