Пример #1
0
 public Task<bool> InitPlayersAsync()
 {
     return Task<bool>.Factory.StartNew(() =>
     {
         lock (_lockObject)
         {
             _players = new PlayerList();
             _players.CollectionChanged += PlayersOnCollectionChanged;
             if (!File.Exists(PlayersFile)) return false;
             try
             {
                 using (var playersFileStream = File.Open(PlayersFile, FileMode.Open))
                 {
                     var bin = new BinaryFormatter();
                     var players = bin.Deserialize(playersFileStream) as IList<PlayerModel>;
                     if (players == null)
                     {
                         File.Delete(PlayersFile);
                         return false;
                     }
                     foreach (var player in players.Select(playerModel => new Player(playerModel)))
                     {
                         player.LoadBitmap((int)Application.Context.Resources.GetDimension(Resource.Dimension.AddPlayerItem_imageSize));
                         _players.Add(player, false);
                     }
                 }
             }
             catch (Exception ex)
             {
                 GaService.TrackAppException(this.ToString(), "InitPlayersAsync", ex, false);
                 File.Delete(PlayersFile);
                 return false;
             }
         }
         return true;
     });
 }
Пример #2
0
 private Rep()
 {
     _players = new PlayerList();
 }