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

Save() public method

Saves a IHighscoreTable to a XML formatted file.
public Save ( IHighscoreTable table ) : void
table IHighscoreTable The concrete implementation of a table.
return void
        public void Save(IHighscoreTable table)
        {
            XDocument highscoreDoc = new XDocument(
                new XElement(
                    "highscoreTable",
                    new XElement(
                        "players",
                        from player in table.Table
                        select new XElement(
                            "player",
                                new XElement("name", player.Name),
                                new XElement("moves", player.Moves),
                                new XElement("time", player.Time)))));

            try
            {
                highscoreDoc.Save(this.FileName);
            }
            catch (Exception ex)
            {
                Logger.Error("Cannot save highscore in xml file.", ex);
                throw;
            }
        }