コード例 #1
0
        public static List <Player> LoadPlayerList()
        {
            string        xmlData    = File.ReadAllText(dataPath);
            List <Player> playerList = XMLConvert.XMLToObject(xmlData);

            return(playerList);
        }
コード例 #2
0
        public static void SavePlayer(Player player)
        {
            List <Player> playerList = LoadPlayerList();

            playerList.Add(player);
            string xmlData = XMLConvert.ObjectToXml(playerList);

            File.WriteAllText(dataPath, xmlData);
        }
コード例 #3
0
        public static void SaveData(Player player)
        {
            List <Player> playerList = LoadPlayerList();
            Player        oldPlayer  = playerList
                                       .FirstOrDefault(p => p.ID == player.ID);

            playerList.Remove(oldPlayer);
            playerList.Add(player);
            string xmlData = XMLConvert.ObjectToXml(playerList);

            File.WriteAllText(dataPath, xmlData);
        }