private void ExportColors(object colorsToExport, GroupExportedColorsBy method) { var colors = SerializationHelper.ConvertToDesiredColorFormats((IList)colorsToExport, ColorRepresentations, method); var dialog = new SaveFileDialog { Title = "Save selected colors to", Filter = "Text Files (*.txt)|*.txt|Json Files (*.json)|*.json", }; if (dialog.ShowDialog() == true) { var extension = Path.GetExtension(dialog.FileName); var contentToWrite = extension.ToUpperInvariant() switch { ".TXT" => colors.ToTxt(';'), ".JSON" => colors.ToJson(), _ => string.Empty }; File.WriteAllText(dialog.FileName, contentToWrite); SessionEventHelper.Event.EditorColorsExported = true; } }