Ejemplo n.º 1
0
        private async void OnGetReposClick()
        {
            ToggleBusy(true);

            try
            {
                ReposBox.ItemsSource = null;
                ReposBox.IsEnabled   = false;

                //Ensure the client is ready to go
                GetBitBucketClient(GetPassword(), true);

                //Download the repository data
                var repos = (await _BitbucketClient.GetAsync <RepositoryList>());

                //Put it in the List Box
                ReposBox.ItemsSource  = repos.values;
                ReposBox.SelectedItem = repos.values.FirstOrDefault();
                ReposBox.IsEnabled    = true;
            }
            catch (Exception ex)
            {
                await HandleException($"An error occurred while attempting to get repos.");
            }

            ToggleBusy(false);
        }
Ejemplo n.º 2
0
        public async Task GetPerformanceTest()
        {
            var countryCodeClient = new RestClientDotNet.RestClient(new NewtonsoftSerializationAdapter(), new Uri("http://services.groupkt.com/country/get/all"));

            groupktResult <CountriesResult> countryData = null;

            var startTime = DateTime.Now;

            for (var i = 0; i < 15; i++)
            {
                countryData = await countryCodeClient.GetAsync <groupktResult <CountriesResult> >();
            }

            var restClientTotalMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;

            Console.WriteLine($"RestClient Get : Total Milliseconds:{ restClientTotalMilliseconds}");


            startTime = DateTime.Now;
            var restSharpClient = new RestSharp.RestClient("http://services.groupkt.com");

            var request = new RestRequest(Method.GET)
            {
                Resource = "/country/get/all"
            };

            for (var i = 0; i < 15; i++)
            {
                var taskCompletionSource = new TaskCompletionSource <groupktResult <CountriesResult> >();
                var response             = restSharpClient.ExecuteAsync <groupktResult <CountriesResult> >(request, (a) => { taskCompletionSource.SetResult(a.Data); });
                countryData = await taskCompletionSource.Task;
            }

            var restSharpTotalMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;

            Console.WriteLine($"RestSharp Get : Total Milliseconds:{ restSharpTotalMilliseconds}");

            Assert.IsTrue(restClientTotalMilliseconds < restSharpTotalMilliseconds, "😞 RestSharp wins.");

            Console.WriteLine("🏆 RestClient Wins!!!");
        }