public IEnumerable <GameSetting> GetAllGameSettings() { var allDetectedGameSettings = new List <FileInfo>(); allDetectedGameSettings.AddRange(_fileSystemDal.GetFiles(_defaultGameSettingsFilesPath)); allDetectedGameSettings.AddRange(_fileSystemDal.GetFiles(_customGameSettingsFilesPath)); foreach (var file in allDetectedGameSettings) { GameSetting data = null; try { var jsonFileData = _fileSystemDal.ReadAllText(file.FullName); data = JsonConvert.DeserializeObject <GameSetting>(jsonFileData); } catch (Exception e) { Console.WriteLine(e); } if (data != null) { yield return(data); } } }
private IEnumerable <FileInfo> GetExeInFolderAndSubFolders(string gameRootFolder) { //Return exes var filesFound = _fileSystemDal.GetFiles(gameRootFolder); foreach (var fileInfo in filesFound) { var ext = Path.GetExtension(fileInfo.Name); if (ext == ".exe") { yield return(fileInfo); } } //Browse var subFolders = _fileSystemDal.DirectoryGetChildren(gameRootFolder); foreach (var subFolder in subFolders) { var results = GetExeInFolderAndSubFolders(subFolder.FullName); foreach (var result in results) { yield return(result); } } }