| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- 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;
- }
- }
- }
|