private static SystemConfiguration LoadModelFromCSV() { //var serializer = new SystemConfigurationJSONSerializer(); var serializer = new SystemConfigurationCSVSerializer(); var openFileDialog = new OpenFileDialog { Filter = @"CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; bool?result = openFileDialog.ShowDialog(); if (result.HasValue && result.Value == true) { return(serializer.Deserialize(openFileDialog.FileName)); } return(null); }
private static void SaveModelToCSV(SystemConfiguration configuration) { //var serializer = new SystemConfigurationJSONSerializer(); var serializer = new SystemConfigurationCSVSerializer(); var sitename = configuration.configuration[@"site.name"].value.ToLower().Replace(' ', '_'); var date = DateTime.Now.ToString(@"yyyyMMdd_HHmmss"); var fname = sitename + @"_config_" + date + @".csv"; var saveFileDialog = new SaveFileDialog { FileName = fname, DefaultExt = @".csv", Filter = @"CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; bool?result = saveFileDialog.ShowDialog(); if (result.HasValue && result.Value) { serializer.Serialize(configuration, saveFileDialog.FileName); } }