BalloonsPop.Highscore.HighscoreHandlingStrategies.XmlHandlingStrategy.Load C# (CSharp) Method

Load() public method

Loads a IHighscoreTable from a XML formatted file.
public Load ( ) : IHighscoreTable
return IHighscoreTable
        public IHighscoreTable Load()
        {
            try
            {
                XDocument highscoreDoc = XDocument.Load(this.FileName);
                var playerScores = highscoreDoc.Descendants("player")
                        .Select(x => new PlayerScore(
                        x.Element("name").Value,
                        int.Parse(x.Element("moves").Value),
                        DateTime.Parse(x.Element("time").Value)))
                        .ToList();

                return new HighscoreTable(playerScores);
            }
            catch (Exception)
            {
                Logger.Warn("No highscore.xml, falling back to empty highscore table.");
                return new HighscoreTable();
            }
        }