Index: Core/Gui/src/Core.Gui/Commands/GuiExportHandler.cs =================================================================== diff -u -r434415295de74c310ce6d3cdd0100c28838cf9ea -r4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec --- Core/Gui/src/Core.Gui/Commands/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision 434415295de74c310ce6d3cdd0100c28838cf9ea) +++ Core/Gui/src/Core.Gui/Commands/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision 4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec) @@ -106,7 +106,7 @@ { foreach (ExportInfo exportInfo in supportedExportInfos) { - selectExportInfoDialog.AddItemType(GetItemName(exportInfo), + selectExportInfoDialog.AddItemType(GetItemName(exportInfo, source), exportInfo.Category, exportInfo.Image, exportInfo); @@ -121,34 +121,36 @@ return null; } - private static string GetItemName(ExportInfo exportInfo) + private static string GetItemName(ExportInfo exportInfo, object source) { + string exportInfoName = exportInfo.Name(source); return exportInfo.Extension != null - ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfo.Name, exportInfo.Extension) - : exportInfo.Name; + ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfoName, exportInfo.Extension) + : exportInfoName; } private static void ExportItem(ExportInfo exportInfo, object source) { string exportFilePath = exportInfo.GetExportPath(); + string exportInfoName = exportInfo.Name(source); if (exportFilePath != null) { log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Start_exporting_DataType_0_, - exportInfo.Name); + exportInfoName); IFileExporter exporter = exportInfo.CreateFileExporter(source, exportFilePath); if (exporter.Export()) { log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Data_exported_to_File_0, exportFilePath); log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_successful, - exportInfo.Name); + exportInfoName); } else { log.ErrorFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_failed, - exportInfo.Name); + exportInfoName); } } } Index: Core/Gui/src/Core.Gui/Plugin/ExportInfo.cs =================================================================== diff -u -r434415295de74c310ce6d3cdd0100c28838cf9ea -r4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec --- Core/Gui/src/Core.Gui/Plugin/ExportInfo.cs (.../ExportInfo.cs) (revision 434415295de74c310ce6d3cdd0100c28838cf9ea) +++ Core/Gui/src/Core.Gui/Plugin/ExportInfo.cs (.../ExportInfo.cs) (revision 4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec) @@ -56,9 +56,13 @@ public Func IsEnabled { get; set; } /// - /// Gets or sets the name of the export information. + /// Gets or sets the name of the export information. Function arguments: + /// + /// The data to export. + /// out - The name of the export information. + /// /// - public string Name { get; set; } + public Func Name { get; set; } /// /// Gets or sets the file extension of the export information. @@ -117,9 +121,13 @@ public Func IsEnabled { get; set; } /// - /// Gets or sets the name of the export information. + /// Gets or sets the name of the export information. Function arguments: + /// + /// The data to export. + /// out - The name of the export information. + /// /// - public string Name { get; set; } + public Func Name { get; set; } /// /// Gets or sets the file extension of the export information. @@ -158,7 +166,7 @@ DataType = exportInfo.DataType, CreateFileExporter = (data, filePath) => exportInfo.CreateFileExporter?.Invoke((TData) data, filePath), IsEnabled = data => exportInfo.IsEnabled == null || exportInfo.IsEnabled((TData) data), - Name = exportInfo.Name, + Name = data => exportInfo.Name?.Invoke((TData) data), Category = exportInfo.Category, Image = exportInfo.Image, Extension = exportInfo.Extension, Index: Core/Gui/test/Core.Gui.Test/Commands/GuiExportHandlerTest.cs =================================================================== diff -u -re848b504d265b0c9443afc069a3b31227af46409 -r4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec --- Core/Gui/test/Core.Gui.Test/Commands/GuiExportHandlerTest.cs (.../GuiExportHandlerTest.cs) (revision e848b504d265b0c9443afc069a3b31227af46409) +++ Core/Gui/test/Core.Gui.Test/Commands/GuiExportHandlerTest.cs (.../GuiExportHandlerTest.cs) (revision 4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec) @@ -162,7 +162,7 @@ { new ExportInfo { - Name = exportInfoName, + Name = i => exportInfoName, CreateFileExporter = (data, filePath) => { Assert.AreEqual(expectedData, data); @@ -204,7 +204,7 @@ { new ExportInfo { - Name = exportInfoName, + Name = i => exportInfoName, CreateFileExporter = (data, filePath) => exporter, GetExportPath = () => targetExportFileName } @@ -368,15 +368,15 @@ var exportInfo1 = new ExportInfo { - Name = "Name 1", + Name = i => "Name 1", Category = "Category 1", Image = Resources.Busy_indicator, Extension = hasFileExtension ? "extension 1" : null }; var exportInfo2 = new ExportInfo { - Name = "Name 2", + Name = i => "Name 2", Category = "Category 2", Image = Resources.DeleteIcon, Extension = hasFileExtension ? "extension 2" : null @@ -395,14 +395,16 @@ Assert.AreEqual("Kies wat u wilt exporteren", dialogText); Assert.AreEqual(2, listViewItems.Length); + string exportInfo1Name = exportInfo1.Name(1234); string expectedItemName1 = hasFileExtension - ? $"{exportInfo1.Name} (*.{exportInfo1.Extension})" - : exportInfo1.Name; + ? $"{exportInfo1Name} (*.{exportInfo1.Extension})" + : exportInfo1Name; Assert.AreEqual(expectedItemName1, listViewItems[0].Name); Assert.AreEqual(exportInfo1.Category, listViewItems[0].Group); + string exportInfo2Name = exportInfo2.Name(1234); string expectedItemName2 = hasFileExtension - ? $"{exportInfo2.Name} (*.{exportInfo2.Extension})" - : exportInfo2.Name; + ? $"{exportInfo2Name} (*.{exportInfo2.Extension})" + : exportInfo2Name; Assert.AreEqual(expectedItemName2, listViewItems[1].Name); Assert.AreEqual(exportInfo2.Category, listViewItems[1].Group); Index: Core/Gui/test/Core.Gui.Test/Plugin/ExportInfoTest.cs =================================================================== diff -u -r781a97409ffc49e5b666a7856f633f46178056df -r4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec --- Core/Gui/test/Core.Gui.Test/Plugin/ExportInfoTest.cs (.../ExportInfoTest.cs) (revision 781a97409ffc49e5b666a7856f633f46178056df) +++ Core/Gui/test/Core.Gui.Test/Plugin/ExportInfoTest.cs (.../ExportInfoTest.cs) (revision 4a5792d2ea470b6a2952bd7deeb6dc879f57e1ec) @@ -84,7 +84,7 @@ { CreateFileExporter = (data, filePath) => fileExporter, IsEnabled = data => false, - Name = name, + Name = data => name, Extension = extension, Category = category, Image = image, @@ -104,7 +104,7 @@ Assert.AreSame(fileExporter, convertedInfo.CreateFileExporter(12, string.Empty)); Assert.IsNotNull(convertedInfo.IsEnabled); Assert.IsFalse(convertedInfo.IsEnabled(12)); - Assert.AreEqual(name, info.Name); + Assert.AreEqual(name, info.Name(12)); Assert.AreEqual(extension, info.Extension); Assert.AreEqual(category, info.Category); Assert.AreSame(image, info.Image);