Index: Core/Common/src/Core.Common.Gui/Commands/GuiExportHandler.cs
===================================================================
diff -u -rc4956adaabe6d54f55069ef05be2fbde323de015 -r8211d3c08096ce8eec50680e011296d082e13358
--- Core/Common/src/Core.Common.Gui/Commands/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision c4956adaabe6d54f55069ef05be2fbde323de015)
+++ Core/Common/src/Core.Common.Gui/Commands/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision 8211d3c08096ce8eec50680e011296d082e13358)
@@ -127,14 +127,14 @@
private static string GetItemName(ExportInfo exportInfo)
{
- return exportInfo.FileFilterGenerator != null
- ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfo.Name, exportInfo.FileFilterGenerator.Extension)
+ return exportInfo.Extension != null
+ ? string.Format(Resources.GetItemName_Name_0_FileExtension_1, exportInfo.Name, exportInfo.Extension)
: exportInfo.Name;
}
private void ExportItemUsingDialog(ExportInfo exportInfo, object source)
{
- string exportFilePath = ExportHelper.GetFilePath(inquiryHelper, exportInfo.FileFilterGenerator);
+ string exportFilePath = exportInfo.GetExportPath();
if (exportFilePath != null)
{
Index: Core/Common/src/Core.Common.Gui/Plugin/ExportInfo.cs
===================================================================
diff -u -r7262d57d1c71168248d6779269d425773b9624fc -r8211d3c08096ce8eec50680e011296d082e13358
--- Core/Common/src/Core.Common.Gui/Plugin/ExportInfo.cs (.../ExportInfo.cs) (revision 7262d57d1c71168248d6779269d425773b9624fc)
+++ Core/Common/src/Core.Common.Gui/Plugin/ExportInfo.cs (.../ExportInfo.cs) (revision 8211d3c08096ce8eec50680e011296d082e13358)
@@ -23,7 +23,6 @@
using System.Drawing;
using Core.Common.Base.IO;
using Core.Common.Gui.Properties;
-using Core.Common.Util;
namespace Core.Common.Gui.Plugin
{
@@ -62,6 +61,11 @@
public string Name { get; set; }
///
+ /// Gets or sets the file extension of the export information.
+ ///
+ public string Extension { get; set; }
+
+ ///
/// Gets or sets the category of the export information.
///
/// Should never return null.
@@ -74,17 +78,12 @@
public Image Image { get; set; } = Resources.ExportIcon;
///
- /// Gets or sets the file filter generator of the export information used to make file filters.
- ///
- public FileFilterGenerator FileFilterGenerator { get; set; }
-
- ///
/// Gets or sets the method used to get the path where the export should save the data. Function arguments:
///
/// - out - the path to export to.
///
///
- public Func GetExportPath { get; set; }
+ public Func GetExportPath { get; set; }
}
///
@@ -123,6 +122,11 @@
public string Name { get; set; }
///
+ /// Gets or sets the file extension of the export information.
+ ///
+ public string Extension { get; set; }
+
+ ///
/// Gets or sets the category of the export information.
///
/// Should never return null.
@@ -135,17 +139,12 @@
public Image Image { get; set; } = Resources.ExportIcon;
///
- /// Gets or sets the file filter generator of the export information used to make file filters.
- ///
- public FileFilterGenerator FileFilterGenerator { get; set; }
-
- ///
/// Gets or sets the method used to get the path where the export should save the data. Function arguments:
///
/// - out - the path to export to.
///
///
- public Func GetExportPath { get; set; }
+ public Func GetExportPath { get; set; }
///
/// Performs an implicit conversion from to .
@@ -162,8 +161,8 @@
Name = exportInfo.Name,
Category = exportInfo.Category,
Image = exportInfo.Image,
- FileFilterGenerator = exportInfo.FileFilterGenerator,
- GetExportPath = fileFilter => exportInfo.GetExportPath?.Invoke(fileFilter)
+ Extension = exportInfo.Extension,
+ GetExportPath = () => exportInfo.GetExportPath?.Invoke()
};
}
}
Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiExportHandlerTest.cs
===================================================================
diff -u -r56d072b8342f3e54ba89124ab918bd1529e257a3 -r8211d3c08096ce8eec50680e011296d082e13358
--- Core/Common/test/Core.Common.Gui.Test/Commands/GuiExportHandlerTest.cs (.../GuiExportHandlerTest.cs) (revision 56d072b8342f3e54ba89124ab918bd1529e257a3)
+++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiExportHandlerTest.cs (.../GuiExportHandlerTest.cs) (revision 8211d3c08096ce8eec50680e011296d082e13358)
@@ -32,7 +32,6 @@
using Core.Common.Gui.Plugin;
using Core.Common.Gui.Properties;
using Core.Common.TestUtil;
-using Core.Common.Util;
using Core.Common.Util.Reflection;
using NUnit.Extensions.Forms;
using NUnit.Framework;
@@ -138,7 +137,6 @@
{
new ExportInfo
{
- FileFilterGenerator = new FileFilterGenerator(),
CreateFileExporter = (o, s) => exporter
}
});
@@ -178,7 +176,6 @@
new ExportInfo
{
Name = exportInfoName,
- FileFilterGenerator = new FileFilterGenerator(),
CreateFileExporter = (data, filePath) =>
{
Assert.AreEqual(expectedData, data);
@@ -227,7 +224,6 @@
new ExportInfo
{
Name = exportInfoName,
- FileFilterGenerator = new FileFilterGenerator(),
CreateFileExporter = (data, filePath) => exporter
}
});
@@ -363,7 +359,7 @@
[TestCase(true)]
[TestCase(false)]
[Apartment(ApartmentState.STA)]
- public void ExportFrom_MultipleSupportedExportersAvailableWithCustomSelectionDialogStyling_GivesExpectedSelectionDialog(bool hasFileFilterGenerator)
+ public void ExportFrom_MultipleSupportedExportersAvailableWithCustomSelectionDialogStyling_GivesExpectedSelectionDialog(bool hasFileExtension)
{
// Setup
var mockRepository = new MockRepository();
@@ -393,15 +389,15 @@
Name = "Name 1",
Category = "Category 1",
Image = Resources.Busy_indicator,
- FileFilterGenerator = hasFileFilterGenerator ? new FileFilterGenerator("extension 1") : null
+ Extension = hasFileExtension ? "extension 1" : null
};
var exportInfo2 = new ExportInfo
{
Name = "Name 2",
Category = "Category 2",
Image = Resources.DeleteIcon,
- FileFilterGenerator = hasFileFilterGenerator ? new FileFilterGenerator("extension 2") : null
+ Extension = hasFileExtension ? "extension 2" : null
};
var exportHandler = new GuiExportHandler(mainWindow, new List
@@ -417,13 +413,13 @@
Assert.AreEqual("Kies wat u wilt exporteren", dialogText);
Assert.AreEqual(2, listViewItems.Length);
- string expectedItemName1 = hasFileFilterGenerator
- ? $"{exportInfo1.Name} (*.{exportInfo1.FileFilterGenerator.Extension})"
+ string expectedItemName1 = hasFileExtension
+ ? $"{exportInfo1.Name} (*.{exportInfo1.Extension})"
: exportInfo1.Name;
Assert.AreEqual(expectedItemName1, listViewItems[0].Name);
Assert.AreEqual(exportInfo1.Category, listViewItems[0].Group);
- string expectedItemName2 = hasFileFilterGenerator
- ? $"{exportInfo2.Name} (*.{exportInfo2.FileFilterGenerator.Extension})"
+ string expectedItemName2 = hasFileExtension
+ ? $"{exportInfo2.Name} (*.{exportInfo2.Extension})"
: exportInfo2.Name;
Assert.AreEqual(expectedItemName2, listViewItems[1].Name);
Assert.AreEqual(exportInfo2.Category, listViewItems[1].Group);
Index: Core/Common/test/Core.Common.Gui.Test/Plugin/ExportInfoTest.cs
===================================================================
diff -u -rc4956adaabe6d54f55069ef05be2fbde323de015 -r8211d3c08096ce8eec50680e011296d082e13358
--- Core/Common/test/Core.Common.Gui.Test/Plugin/ExportInfoTest.cs (.../ExportInfoTest.cs) (revision c4956adaabe6d54f55069ef05be2fbde323de015)
+++ Core/Common/test/Core.Common.Gui.Test/Plugin/ExportInfoTest.cs (.../ExportInfoTest.cs) (revision 8211d3c08096ce8eec50680e011296d082e13358)
@@ -24,7 +24,6 @@
using Core.Common.Gui.Plugin;
using Core.Common.Gui.Properties;
using Core.Common.TestUtil;
-using Core.Common.Util;
using NUnit.Framework;
using Rhino.Mocks;
@@ -44,9 +43,9 @@
Assert.IsNull(info.CreateFileExporter);
Assert.IsNull(info.IsEnabled);
Assert.IsNull(info.Name);
+ Assert.IsNull(info.Extension);
Assert.AreEqual("Algemeen", info.Category);
TestHelper.AssertImagesAreEqual(Resources.ExportIcon, info.Image);
- Assert.IsNull(info.FileFilterGenerator);
Assert.IsNull(info.GetExportPath);
}
@@ -61,9 +60,9 @@
Assert.IsNull(info.CreateFileExporter);
Assert.IsNull(info.IsEnabled);
Assert.IsNull(info.Name);
+ Assert.IsNull(info.Extension);
Assert.AreEqual("Algemeen", info.Category);
TestHelper.AssertImagesAreEqual(Resources.ExportIcon, info.Image);
- Assert.IsNull(info.FileFilterGenerator);
Assert.IsNull(info.GetExportPath);
}
@@ -76,20 +75,20 @@
mocks.ReplayAll();
const string name = "name";
+ const string extension = ".txt";
const string category = "category";
var image = new Bitmap(16, 16);
- var generator = new FileFilterGenerator();
const string exportPath = "C:/path";
var info = new ExportInfo
{
CreateFileExporter = (data, filePath) => fileExporter,
IsEnabled = data => false,
Name = name,
+ Extension = extension,
Category = category,
Image = image,
- FileFilterGenerator = generator,
- GetExportPath = filterGenerator => exportPath
+ GetExportPath = () => exportPath
};
// Precondition
@@ -106,10 +105,10 @@
Assert.IsNotNull(convertedInfo.IsEnabled);
Assert.IsFalse(convertedInfo.IsEnabled(12));
Assert.AreEqual(name, info.Name);
+ Assert.AreEqual(extension, info.Extension);
Assert.AreEqual(category, info.Category);
Assert.AreSame(image, info.Image);
- Assert.AreEqual(generator, info.FileFilterGenerator);
- Assert.AreEqual(exportPath, info.GetExportPath(new FileFilterGenerator()));
+ Assert.AreEqual(exportPath, info.GetExportPath());
mocks.VerifyAll();
}
@@ -134,9 +133,9 @@
Assert.IsNotNull(convertedInfo.IsEnabled);
Assert.IsTrue(convertedInfo.IsEnabled(new object()));
Assert.IsNull(info.Name);
+ Assert.IsNull(info.Extension);
Assert.AreEqual("Algemeen", info.Category);
TestHelper.AssertImagesAreEqual(Resources.ExportIcon, info.Image);
- Assert.IsNull(info.FileFilterGenerator);
Assert.IsNull(info.GetExportPath);
}
}