Exemplo n.º 1
0
        private async Task <string> PerformAnalyzeAsync(string analyzeString, string actionString)
        {
            if ((string.IsNullOrEmpty(analyzeString) == true) || (string.IsNullOrEmpty(actionString) == true))
            {
                return(null);
            }

            var bodyBytesArray = Encoding.UTF8.GetBytes(analyzeString);

            if (bodyBytesArray == null)
            {
                return(null);
            }

            var urlString = PrepareURL(actionString);

            if (string.IsNullOrEmpty(urlString) == true)
            {
                return(null);
            }

            _httpConnectionProxy.URL(urlString)
            .ByteArrayBody(bodyBytesArray)
            .Build();

            var analyzeResponse = await _httpConnectionProxy.PostAsync();

            return(analyzeResponse?.ResponseString);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += async delegate
            {
                string responseString      = "";
                var    httpConnectionProxy = new CMPHttpConnectionProxy();
                httpConnectionProxy.URL("http://www.google.com").Build();

                var httpResponse = await httpConnectionProxy.GetAsync();

                Console.WriteLine(httpResponse.ResponseString);

                await cl.GetBytesWithProgressAsync((httpResponse, progressBytes, totalBytes) =>
                {
                    responseString = string.Concat(responseString, httpResponse.ResponseString);
                    Console.WriteLine("Response:" + responseString);
                    Console.WriteLine("progressBytes: " + progressBytes + "\ntotalBytes: " + totalBytes);
                }); await cl.GetBytesWithProgressAsync((httpResponse, progressBytes, totalBytes) =>
                {
                    responseString = string.Concat(responseString, httpResponse.ResponseString);
                    Console.WriteLine("Response:" + responseString);
                    Console.WriteLine("progressBytes: " + progressBytes + "\ntotalBytes: " + totalBytes);
                });
            };
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            string responseString = "";

            button.Click += async delegate
            {
                button.Text = string.Format("{0} clicks!", count++);

                CMPHttpConnectionProxy cl = new CMPHttpConnectionProxy();
                cl.URL("http://www.google.com").Build();
                await cl.GetBytesWithProgressAsync((httpResponse, progressBytes, totalBytes) =>
                {
                    responseString = string.Concat(responseString, httpResponse.ResponseString);
                    Console.WriteLine("Response:" + responseString);
                    Console.WriteLine("progressBytes: " + progressBytes + "\ntotalBytes: " + totalBytes);
                });
            };
        }