示例#1
0
        public IObservable<IEnumerable<Flight>> GetFlightsFrom(Airport fromAirport)
        {
            var airports = new AirportNamesService().GetAirports();
            var airlines = new AirlineNamesService().GetAirlines();
            var statuses = new StatusService().GetStautses();

            var referenceData = airports
                .ForkJoin(airlines, (allAirports, allAirlines) =>
                                    {
                                        Airports.AddRange(allAirports);
                                        Airlines.AddRange(allAirlines);
                                        return new Unit();
                                    })
                .ForkJoin(statuses, (nothing, allStatuses) =>
                                    {
                                        Statuses.AddRange(allStatuses);
                                        return new Unit();
                                    });

            string url = string.Format(_serviceUrl, 1, 5, fromAirport.Code);

            var flights = from data in referenceData
                          from flight in GetFlightsFrom(url)
                          select flight;

            return flights;
        }
        private void LoadSelectedAirportFromDisk()
        {
            if (!_objectStore.FileExists(ObjectStore.SelectedAirportFilename)) return;

            var savedAirport = _objectStore.Load<Airport>(ObjectStore.SelectedAirportFilename);
            SelectedAirport = Airports.Where(a => a.Code == savedAirport.Code).Single();
        }
 public void Can_delete_an_object()
 {
     var airport = new Airport("LKL", "Lakselv");
     objectStore.Save(airport, ObjectStore.SelectedAirportFilename);
     objectStore.Delete(ObjectStore.SelectedAirportFilename);
     objectStore.Load<Airport>(ObjectStore.SelectedAirportFilename);
 }
        public IObservable<IEnumerable<Flight>> GetFlightsFrom(Airport fromAirport)
        {
            FromAirport = fromAirport;
            GetFlightsFromWasCalled = true;

            var allFlights = new List<IEnumerable<Flight>> { FlightsToReturn };
            return allFlights.ToObservable();
        }
        public void Can_persist_a_simple_object()
        {
            var airport = new Airport("LKL", "Lakselv");

            objectStore.Save(airport, ObjectStore.SelectedAirportFilename);
            var airportRead = objectStore.Load<Airport>(ObjectStore.SelectedAirportFilename);

            Assert.AreEqual(airport.Code, airportRead.Code);
            Assert.AreEqual(airport.Name, airportRead.Name);
        }
 public IObservable<IEnumerable<Flight>> GetFlightsFrom(Airport fromAirport)
 {
     var allFlights = new List<IEnumerable<Flight>> { CreateDepartures() };
     return allFlights.ToObservable();
 }
        public void AirportSelected(Airport airport)
        {
            Arrivals.Clear();
            Departures.Clear();

            _flightsService.GetFlightsFrom(_selectedAirport).Subscribe(LoadFlights);
        }