private static void FillModelFromIniFile(PT4DatabaseSettingsProvider model) { var file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), pt4RelativeConfigPath); if (File.Exists(file)) { var keyValuePairs = IniFileHelpers.ReadKeyValuePairs("Database", file); var server = GetKeyValue("Default.Postgres.Server", "Postgres.Server", keyValuePairs); var port = GetKeyValue("Default.Postgres.Port", "Postgres.Port", keyValuePairs); var user = GetKeyValue("Default.Postgres.User", "Postgres.User", keyValuePairs); var password = GetKeyValue("Default.Postgres.Password", "Postgres.Password", keyValuePairs); if (!string.IsNullOrWhiteSpace(server)) { model.Server = server; } if (!string.IsNullOrWhiteSpace(port)) { model.Port = port; } if (!string.IsNullOrWhiteSpace(user)) { model.UserName = user; } if (!string.IsNullOrWhiteSpace(password)) { model.Password = password; } } }
public static PT4DatabaseSettingsProvider GetPT4DatabaseSettings() { var model = new PT4DatabaseSettingsProvider(); FillModelFromIniFile(model); return(model); }