Ejemplo n.º 1
0
        private async Task GetDataAsync()
        {
            if (this.buses.Count != 0)
                return;

            Uri dataUri = new Uri("ms-appx:///BusHelper/Buses.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
            string jsonText = await FileIO.ReadTextAsync(file);
            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray jsonArray = jsonObject["Buses"].GetArray();

            foreach (JsonValue busValue in jsonArray)
            {
                JsonObject busObject = busValue.GetObject();
                Bus bus = new Bus(busObject["UniqueId"].GetString(),
                                  busObject["Name"].GetString(),
                                  busObject["Stops"].GetString(),
                                  busObject["Note"].GetString());

                foreach (JsonValue tripValue in busObject["Trips"].GetArray())
                {
                    JsonObject tripObject = tripValue.GetObject();
                    bus.Trips.Add(new Trip(tripObject["UniqueId"].GetString(),
                                            tripObject["StartStop"].GetString(),
                                            tripObject["PassedStop"].GetString(),
                                            tripObject["EndStop"].GetString(),
                                            TimeSpan.Parse(tripObject["StartTime"].GetString()),
                                            TimeSpan.Parse(tripObject["EndTime"].GetString()),
                                            tripObject["Note"].GetString()));
                }
                this.Buses.Add(bus);
            }
        }
Ejemplo n.º 2
0
 public Bus(Bus bus, List<Trip> trips)
 {
     this.Name = bus.Name;
     this.Note = bus.Note;
     this.Trips = trips;
 }
Ejemplo n.º 3
0
 public Bus(Bus bus, List <Trip> trips)
 {
     this.Name  = bus.Name;
     this.Note  = bus.Note;
     this.Trips = trips;
 }