/// <summary> /// Save the entire station list to storage /// </summary> private static void SaveStations() { PersistentStorage.SetIntItem(RecentStationsSizeName, stations.Count); for (int stationIndex = 0; stationIndex < stations.Count; ++stationIndex) { PersistentStorage.SetStringItem(RecentStationName + stationIndex, stations[stationIndex]); } }
/// <summary> /// Save the entire trip list to storage /// </summary> private static void SaveTrips() { PersistentStorage.SetIntItem(TrainTripsSizeName, trips.Count); for (int tripIndex = 0; tripIndex < trips.Count; ++tripIndex) { PersistentStorage.SetStringItem(TrainTripFromName + tripIndex, trips[tripIndex].From); PersistentStorage.SetStringItem(TrainTripToName + tripIndex, trips[tripIndex].To); PersistentStorage.SetStringItem(TrainTripFromCodeName + Trips.Count, trips[tripIndex].FromCode); PersistentStorage.SetStringItem(TrainTripToCodeName + Trips.Count, trips[tripIndex].ToCode); } }
/// <summary> /// Add a new trip to the collection and store. /// </summary> /// <param name="trip"></param> public static void AddTrip(TrainTrip trip) { // Store the trip PersistentStorage.SetStringItem(TrainTripFromName + Trips.Count, trip.From); PersistentStorage.SetStringItem(TrainTripToName + Trips.Count, trip.To); PersistentStorage.SetStringItem(TrainTripFromCodeName + Trips.Count, trip.FromCode); PersistentStorage.SetStringItem(TrainTripToCodeName + Trips.Count, trip.ToCode); // Add to the list Trips.Add(trip); // Update the count PersistentStorage.SetIntItem(TrainTripsSizeName, Trips.Count); }