public GameViewModel(Config cfg) { _currWolf = _wolfLT; animator.ReadyToCatch += EggReadyToCatch; animator.LifeActivate += LifeActive; _config = cfg; if (File.Exists("LeaderBord.ldr")) { try { _scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr"); } catch (InvalidOperationException) { _scores = Score.GetDeffaultScoreList(); CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord"); messageBox.ShowDialog(); MySerializer.SerializeXml <List <Score> >(_scores, "LeaderBord.ldr"); } } else { _scores = Score.GetDeffaultScoreList(); } }
public LeaderBordViewModel(Config cfg) { if (File.Exists("LeaderBord.ldr")) { try { Scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr"); } catch (InvalidOperationException) { Scores = Score.GetDeffaultScoreList(); CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord"); messageBox.ShowDialog(); MySerializer.SerializeXml <List <Score> >(Scores, "LeaderBord.ldr"); } } else { Scores = Score.GetDeffaultScoreList(); } Scores.Sort(); Scores.Reverse(); _config = cfg; }
public void Xml_Serialization_Deserialization_Equal_Test(string serFileName) { MySerializer.SerializeXml(TestCatalog.StandardDir, serFileName); _desDir = MySerializer.DeserializeFromFile(serFileName, "-xml"); File.Delete(serFileName); Assert.That(_desDir, Is.EqualTo(TestCatalog.StandardDir)); }
private void ScoreCalculation() { if (CurrentScore > _scores.Min().LeaderScore) { _scores.Remove(_scores.Min()); NewHightScore NHS = new NewHightScore(); NewHightScoreViewModel NHSVM = NHS.DataContext as NewHightScoreViewModel; NHSVM.LeaderNameChanged += LeaderNameChanged; NHS.ShowDialog(); _scores.Add(new Score(CurrentScore, _leaderName)); MySerializer.SerializeXml <List <Score> >(_scores, "LeaderBord.ldr"); } }
private void LoadSettings() { if (File.Exists($"config.cfg")) { try { _config = MySerializer.DeserializeXml <Config>("config.cfg"); } catch (InvalidOperationException) { _config.SetDeffault(); CustomMessageBox messageBox = new CustomMessageBox("File config.cfg is damaged. Reset to default settings"); messageBox.ShowDialog(); MySerializer.SerializeXml <Config>(_config, "config.cfg"); } } else { _config.SetDeffault(); } }