public static GeneralSettings LoadGeneralSettings(string path, IMigrationService service = null) { if (!File.Exists(path)) { return(new GeneralSettings { Languages = new List <GeneralLanguageSettings>() }); } JObject jSettings; using (var reader = File.OpenText(path)) using (var jsonReader = new JsonTextReader(reader)) { try { jSettings = (JObject)JToken.ReadFrom(jsonReader); } catch (JsonReaderException) { return(new GeneralSettings { Languages = new List <GeneralLanguageSettings>() }); } } var languages = new List <GeneralLanguageSettings>(); foreach (var jSetting in jSettings) { if (!(jSetting.Value is JObject jLanguageSettings)) { continue; } var language = new GeneralLanguageSettings { Name = jSetting.Key, }; ParseGeneralSettings(jLanguageSettings, ref language, out var properties); if (!(service is null)) { service.MigrateGeneral(properties, ref language); } languages.Add(language); } return(new GeneralSettings { Languages = languages }); }