|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
@ -23,13 +24,13 @@ namespace DataContractPersistence
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Path (relative to the project)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
|
|
|
|
|
public string FilePath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Trek_12");
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Load all the data from XML file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>A tuple with the lists of players, games, maps and best scores</returns>
|
|
|
|
|
public (List<Player>, List<Game>, List<Map>, List<BestScore>) LoadData()
|
|
|
|
|
public (ObservableCollection<Player>, ObservableCollection<Game>, ObservableCollection<Map>, ObservableCollection<BestScore>) LoadData()
|
|
|
|
|
{
|
|
|
|
|
var serializer = new DataContractSerializer(typeof(DataToPersist));
|
|
|
|
|
DataToPersist? data = new DataToPersist();
|
|
|
|
@ -49,7 +50,7 @@ namespace DataContractPersistence
|
|
|
|
|
/// <param name="games"></param>
|
|
|
|
|
/// <param name="maps"></param>
|
|
|
|
|
/// <param name="bestScores"></param>
|
|
|
|
|
public void SaveData(List<Player> players, List<Game> games, List<Map> maps, List<BestScore> bestScores)
|
|
|
|
|
public void SaveData(ObservableCollection<Player> players, ObservableCollection<Game> games, ObservableCollection<Map> maps, ObservableCollection<BestScore> bestScores)
|
|
|
|
|
{
|
|
|
|
|
if(!Directory.Exists(FilePath))
|
|
|
|
|
{
|
|
|
|
|