Ejemplo n.º 1
0
        // >> autocomplete-remote-do-in-background-xamarin
        protected override Java.Lang.Void RunInBackground(params string[] @params)
        {
            HttpURLConnection urlConnection = null;

            try
            {
                URL url = new URL
                              ("http://www.telerik.com/docs/default-source/ui-for-ios/airports.json?sfvrsn=2");

                urlConnection = (HttpURLConnection)url.OpenConnection();

                urlConnection.RequestMethod        = "GET";
                urlConnection.UseCaches            = false;
                urlConnection.AllowUserInteraction = false;
                urlConnection.Connect();
                HttpStatus status = urlConnection.ResponseCode;

                if (status.Equals(HttpStatus.Ok))
                {
                    BufferedReader reader = new BufferedReader
                                                (new InputStreamReader(urlConnection.InputStream));
                    char[] buffer = new char[1024];
                    int    n;
                    Writer writer = new Java.IO.StringWriter();

                    while ((n = reader.Read(buffer)) != -1)
                    {
                        writer.Write(buffer, 0, n);
                    }

                    string json = writer.ToString();

                    try
                    {
                        JSONObject jObj = new JSONObject(json);
                        data = jObj.GetJSONArray("airports");
                    }
                    catch (JSONException ex)
                    {
                        ex.PrintStackTrace();
                    }
                }
            }
            catch (Java.IO.IOException e)
            {
                e.PrintStackTrace();
            }
            finally
            {
                if (urlConnection != null)
                {
                    urlConnection.Disconnect();
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if ResponseError instances are equal
        /// </summary>
        /// <param name="other">Instance of ResponseError to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ResponseError other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     HttpStatus == other.HttpStatus ||

                     HttpStatus.Equals(other.HttpStatus)
                     ) &&
                 (
                     ErrorCode == other.ErrorCode ||

                     ErrorCode.Equals(other.ErrorCode)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     DocumentationLink == other.DocumentationLink ||
                     DocumentationLink != null &&
                     DocumentationLink.Equals(other.DocumentationLink)
                 ) &&
                 (
                     AdditionalInfo == other.AdditionalInfo ||
                     AdditionalInfo != null &&
                     other.AdditionalInfo != null &&
                     AdditionalInfo.SequenceEqual(other.AdditionalInfo)
                 ));
        }