Exemplo n.º 1
0
        public static void ReadAllData(out MainGameData data, string dataFolder, string extension, string application, bool isUserData = false)
        {
            data = new MainGameData();

            if (string.IsNullOrWhiteSpace(dataFolder))
            {
                return;
            }

            if (!Directory.Exists(dataFolder))
            {
                return;
            }

            foreach (var file in Directory.GetFiles(dataFolder, $"*{extension}", SearchOption.TopDirectoryOnly))
            {
                try
                {
                    var fileData = MainGameData.Load(file, isUserData);
                    if (fileData == null)
                    {
                        continue;
                    }

                    if (!fileData.Application.Equals(application, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    data.GameMaps.AddRange(fileData.GameMaps);
                    data.Branches.AddRange(fileData.Branches);
                    data.ServerRegions.AddRange(fileData.ServerRegions);
                }
                catch
                {
                    // do nothing, just swallow the error
                }
            }
        }