| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- namespace Breda_Tour.Data
- {
- class RouteDatabase
- {
- public List<Route> Routes;
-
- public RouteDatabase()
- {
- Routes = new List<Route>();
- readRoutes();
- }
- private void readRoutes()
- {
- string json = File.ReadAllText("Storage/Routes/routes.json");
- JObject JsonObject = JObject.Parse(json);
- IList<JToken> JsonList = JsonObject["Routes"].ToList();
- foreach (JToken route in JsonList)
- {
- Routes.Add(JsonConvert.DeserializeObject<Route>(route.ToString()));
- }
- }
- public ObservableCollection<Route> GetCurrentRoutes()
- {
- ObservableCollection<Route> routes = new ObservableCollection<Route>();
- foreach (var route in Routes)
- {
- if (route.Language == App.Language)
- routes.Add(route);
- }
- return routes;
- }
- }
- }
|