private void btnImport_Click(object sender, EventArgs e) { if (cmbBoxType.SelectedItem == null) { MessageBox.Show("Please select the type of file from combo box !"); } else { string _selectedName = cmbBoxType.Text; IPersonExporter _exporter = exporterFactory.CreateExporter(_selectedName); string _filter = _exporter.Name + "|*" + _exporter.FileExtension; string _filePath = selectFileForOpen(_filter); if (_filePath != null) { BindingList <Person> _loadedList = _exporter.Open(_filePath); personList.Clear(); for (int i = 0; i < _loadedList.Count; i++) { personList.Add(_loadedList[i]); } } } }
private void btnExport_Click(object sender, EventArgs e) { if (cmbBoxType.SelectedItem == null) { MessageBox.Show("Please select the type of file from combo box !"); } else { string _selectedName = cmbBoxType.Text; IPersonExporter _exporter = m_exporterFactory.CreateExporter(_selectedName); string _filter = _exporter.Name + "|*" + _exporter.FileExtension; string _filePath = selectFileForOpen(_filter); if (_filePath != null) { _exporter.Save(_filePath, personList); MessageBox.Show("Data serialized successfully"); } } }