コード例 #1
0
 private void Load(bool onlyIfExists)
 {
     try
     {
         string filename = PPCConfigurationManager.PlayersPath;
         if (onlyIfExists && !File.Exists(filename))
         {
             return;
         }
         List <Player> players = PlayersDb.Load(filename);
         Players = new ObservableCollection <PlayerItem>(players.Select(x => new PlayerItem
         {
             DCINumber   = x.DCINumber,
             FirstName   = x.FirstName,
             LastName    = x.LastName,
             MiddleName  = x.MiddleName,
             CountryCode = x.CountryCode,
             IsJudge     = x.IsJudge
         }).OrderBy(x => x.FirstName, new EmptyStringsAreLast()));
     }
     catch (Exception ex)
     {
         Logger.Exception("Error while loading player file", ex);
         PopupService.DisplayError("Error while loading player file", ex);
     }
 }
コード例 #2
0
 private void Save()
 {
     try
     {
         List <Player> players = Players.Select(x => new Player
         {
             DCINumber   = x.DCINumber,
             FirstName   = x.FirstName,
             LastName    = x.LastName,
             MiddleName  = x.MiddleName,
             CountryCode = x.CountryCode,
             IsJudge     = x.IsJudge
         }).ToList();
         PlayersDb.Save(PPCConfigurationManager.PlayersPath, players);
         Load(false); //TODO crappy workaround to reset row.IsNewItem
     }
     catch (Exception ex)
     {
         Logger.Exception("Error while saving player file", ex);
         PopupService.DisplayError("Error while saving player file", ex);
     }
 }