/* 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>(); } }
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>(); } }
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)); } }
/* 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)); } }