private void SaveConfigToXmlFile() { XmlConfig config = new XmlConfig(); config.ComponentName = txtComponentName.Text; config.OutPutPath = txtOutputFolder.Text; config.PrefixTable = txtPrefixTable.Text; config.PrefixTableForSelect = txtPrefixSelect.Text; config.SelectedTables = new List<string>(); config.IsAutoGeneration = cbAutoGenerate.Checked; foreach (ITable it in lboxTables.SelectedItems) { config.SelectedTables.Add(it.Name); } XmlSerializer serializer = new XmlSerializer(typeof(XmlConfig)); using (TextWriter writer = new StreamWriter(_configFileName)) { serializer.Serialize(writer, config); } }
private void ConfigForm_Load(object sender, EventArgs e) { XmlSerializer serializer = new XmlSerializer(typeof(XmlConfig)); XmlConfig config = new XmlConfig(); if (File.Exists(_configFileName)) { using (StreamReader reader = new StreamReader(_configFileName)) { config = serializer.Deserialize(reader) as XmlConfig; } } if (config != null) { txtOutputFolder.Text = config.OutPutPath; txtComponentName.Text = config.ComponentName; txtPrefixTable.Text = config.PrefixTable; txtPrefixSelect.Text = config.PrefixTableForSelect; cbAutoGenerate.Checked = config.IsAutoGeneration; } if (this.myMeta.Databases[0] != null) { this.lboxTables.DataSource = this.myMeta.Databases[0].Tables; this.lboxTables.DisplayMember = "Name"; this.lboxTables.Refresh(); lboxTables.ClearSelected(); int size = this.lboxTables.Items.Count; for (int i = 0; i < size; i++) { ITable tb = this.lboxTables.Items[i] as ITable; if (tb != null && !string.IsNullOrEmpty(txtPrefixSelect.Text) && (tb.Name.ToLower().StartsWith(txtPrefixSelect.Text.ToLower())) ) { lboxTables.SetSelected(i, true); } if (config != null && config.SelectedTables != null) { if (config.SelectedTables.Contains(tb.Name)) { lboxTables.SetSelected(i, true); } } } } this.zeusInput["path"] = txtOutputFolder.Text; if (config.IsAutoGeneration) { Generate(); } }