Esempio n. 1
0
        /* Instantiates a ScoreDB that will communication with the file at filePath */
        private ScoreDB(string fileName)
        {
            if (fileName == null || fileName.Trim().Length == 0)
            {
                throw new ArgumentException("fileName must not be null or empty");
            }

            this.fileName = fileName;

            if (File.Exists(fileName))
            {
                records = SerializeUtilities <List <ScoreRecord> > .Deserialize(fileName);
            }
            else
            {
                records = new List <ScoreRecord>();
            }
        }
Esempio n. 2
0
        private ScoreDB(string fileName)
        {
            if (fileName == null || fileName.Trim().Length == 0)
            {
                throw new ArgumentException("Имя файла не должно быть пустым");
            }

            this.fileName = fileName;

            if (File.Exists(fileName))
            {
                records = SerializeUtilities <List <ScoreRecord> > .Deserialize(fileName);
            }
            else
            {
                records = new List <ScoreRecord>();
            }
        }
Esempio n. 3
0
        private PlayerDB(string dirPath)
        {
            if (dirPath == null || dirPath.Trim().Length == 0)
            {
                throw new ArgumentException();
            }


            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            this.dirPath = dirPath;


            string[] allFiles = Directory.GetFiles(this.dirPath);
            this.saves = new List <GamePageData>();
            foreach (string file in allFiles)
            {
                saves.Add(SerializeUtilities <GamePageData> .Deserialize(file));
            }
        }
Esempio n. 4
0
        /* Instantiates a playerDB that will communication with the file at filePath */
        private PlayerDB(string dirPath)
        {
            if (dirPath == null || dirPath.Trim().Length == 0)
            {
                throw new ArgumentException("dirPath must not be null or empty");
            }

            /* If the directory does not exist, create it */
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            this.dirPath = dirPath;

            /* Get a listing of all the files in the directory and deserialize each */
            string[] allFiles = Directory.GetFiles(this.dirPath);
            this.saves = new List <GamePageData>();
            foreach (string file in allFiles)
            {
                saves.Add(SerializeUtilities <GamePageData> .Deserialize(file));
            }
        }