/// <summary> /// Read setting from application setting json file (decided not to do StartupProject) /// </summary> private void ReadApplicationSettingsFile() { using (var file = File.OpenText(_applicationSettingsFile)) { var serializer = new JsonSerializer(); var applicationSettings = (ApplicationSettings)serializer.Deserialize(file, typeof(ApplicationSettings)); if (!string.IsNullOrWhiteSpace(applicationSettings.LastServerName)) { ServerNameTextBox.Text = applicationSettings.LastServerName; } var dataProvider = new DatabaseProviders(); ProviderComboBox.DataSource = dataProvider.List; if (!string.IsNullOrWhiteSpace(applicationSettings.DataProvider)) { if (ProviderComboBox.DataSource != null) { var index = ProviderComboBox.FindString(applicationSettings.DataProvider); if (index > -1) { ProviderComboBox.SelectedIndex = index; } } } _scaffoldBuilder = new ScaffoldBuilder(applicationSettings.LastServerName); } }
private void LoadData() { try { if (!DesignMode) { using (StreamReader reader = File.OpenText(Settings.LanguageMappingFile)) { settings.LoadXml(reader.ReadToEnd()); if (settings != null) { PopulateProviders(); } } } int index = ProviderComboBox.FindString(Settings.Driver); if (index != -1) { ProviderComboBox.SelectedIndex = index; } } catch { } }