Esempio n. 1
0
 public Car(double price1, ratePlan type1, Url imageUrl1, double estimatedTotal1, string providerName, string line1, string city)
 {
     // TODO: Complete member initialization
     this.price1 = price1;
     this.type1 = type1;
     this.imageUrl1 = imageUrl1;
     this.estimatedTotal1 = estimatedTotal1;
     this.providerName = providerName;
     this.line1 = line1;
     this.city = city;
 }
Esempio n. 2
0
 public Car(double price1, ratePlan type1, Url imageUrl1, double estimatedTotal1, string providerName, string line1, string city)
 {
     // TODO: Complete member initialization
     this.price1          = price1;
     this.type1           = type1;
     this.imageUrl1       = imageUrl1;
     this.estimatedTotal1 = estimatedTotal1;
     this.providerName    = providerName;
     this.line1           = line1;
     this.city            = city;
 }
Esempio n. 3
0
        private void FindCar(IAsyncResult result)
        {
            cars = new List <Car>();
            var request  = (HttpWebRequest)result.AsyncState;
            var response = (HttpWebResponse)request.EndGetResponse(result);

            using (var stream = response.GetResponseStream())
            {
                var r    = new StreamReader(stream);
                var resp = r.ReadToEnd();
                Dictionary <string, object> values = JsonConvert.DeserializeObject <Dictionary <string, object> >(resp);
                var res   = values["results"] as JArray;
                int count = 0;

                foreach (var _res in res)
                {
                    double latitude   = double.Parse(_res["location"]["latitude"].ToString());
                    double longtitude = double.Parse(_res["location"]["longitude"].ToString());
                    KeyValuePair <double, double> location = new KeyValuePair <double, double>(latitude, longtitude);
                    String providerName = _res["provider"]["company_name"].ToString();
                    String line1        = _res["address"]["line1"].ToString();
                    String city         = _res["address"]["city"].ToString();
                    var    _cars        = _res["cars"] as JArray;
                    foreach (var _car in _cars)
                    {
                        double   price = double.Parse(_car["rates"][0]["price"]["amount"].ToString());
                        String   _type = _car["rates"][0]["type"].ToString();
                        ratePlan type  = getRatePlan(_type);
                        Url      imageUrl;
                        if (_car["images"] != null)
                        {
                            imageUrl = new Url(_car["images"][0]["url"].ToString());
                        }
                        else
                        {
                            imageUrl = new Url("https://cdn3.iconfinder.com/data/icons/transportation-2/41/transportation_car_icon-512.png");
                        }
                        double estimatedTotal = double.Parse(_car["estimated_total"]["amount"].ToString());
                        Car    car            = new Car(price, type, imageUrl, estimatedTotal, providerName, line1, city);
                        cars.Add(car);

                        ++count;
                        if (count == 5)
                        {
                            this.finished = true;
                            return;
                        }
                    }
                }
                this.finished = true;
            }
        }