public static void Load() { string settingsFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); if (!File.Exists(settingsFile)) { throw new FileNotFoundException("Settings file not found, must be in settings.json"); } _current = JsonConvert.DeserializeObject<SettingsJson>(File.ReadAllText(settingsFile), new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); if (string.IsNullOrWhiteSpace(Current.Steam.Username) || string.IsNullOrWhiteSpace(Current.Steam.Password)) { throw new InvalidDataException("Missing Steam credentials in settings file"); } using (var connection = new MySqlConnection(Settings.Current.ConnectionString)) { connection.Open(); // Exception will be caught by whatever called Load() } if (Current.FullRun > 0) { Log.WriteInfo("Settings", "Running full update with option \"{0}\"", Settings.Current.FullRun); // Don't log full runs, regardless of setting Current.LogToFile = false; } else if (!Current.LogToFile) { Log.WriteInfo("Settings", "File logging is disabled"); } }
public static void Load() { string settingsFile = Path.Combine(Application.Path, "settings.json"); if (!File.Exists(settingsFile)) { throw new FileNotFoundException("Settings file not found, must be in settings.json"); } _current = JsonConvert.DeserializeObject<SettingsJson>(File.ReadAllText(settingsFile), new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); if (string.IsNullOrWhiteSpace(Current.Steam.Username) || string.IsNullOrWhiteSpace(Current.Steam.Password)) { throw new InvalidDataException("Missing Steam credentials in settings file"); } // Test database connection, it will throw if connection is unable to be made using (var connection = Database.GetConnection()) { // [crashing intensifies] } if (Current.FullRun != FullRunState.None) { IsFullRun = true; Log.WriteInfo("Settings", "Running full update with option \"{0}\"", Current.FullRun); // Don't log full runs, regardless of setting Current.LogToFile = false; // Don't connect to IRC while doing a full run Current.IRC.Enabled = false; } else if (!Current.LogToFile) { Log.WriteInfo("Settings", "File logging is disabled"); } Current.IRC.Enabled = CanConnectToIRC(); }