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);
                }
            }
        }
예제 #2
0
        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);
                }
            }
        }