Index: Core/Common/src/Core.Common.Base/ApplicationCore.cs =================================================================== diff -u -r14f616f114b9b1a4355e2333bfd348b8e4aae01f -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/src/Core.Common.Base/ApplicationCore.cs (.../ApplicationCore.cs) (revision 14f616f114b9b1a4355e2333bfd348b8e4aae01f) +++ Core/Common/src/Core.Common.Base/ApplicationCore.cs (.../ApplicationCore.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -37,22 +37,6 @@ } } - public IEnumerable FileImporters - { - get - { - return Plugins.SelectMany(plugin => plugin.GetFileImporters()); - } - } - - public IEnumerable FileExporters - { - get - { - return Plugins.SelectMany(plugin => plugin.GetFileExporters()); - } - } - public void AddPlugin(ApplicationPlugin applicationPlugin) { plugins.Add(applicationPlugin); Index: Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs (revision 0) +++ Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; +using Core.Common.Utils.Reflection; + +namespace Core.Common.Base +{ + public static class ApplicationCoreExtensions + { + public static IList GetImporters(this ApplicationCore applicationCore, object target) + { + var targetType = target == null ? null : target.GetType(); + + IList importers = new List(); + + foreach (IFileImporter importer in applicationCore.Plugins.SelectMany(plugin => plugin.GetFileImporters())) + { + if (targetType == null && !importer.CanImportOnRootLevel) + { + //this importer requires something to import into, but we're importing globally (into project or folder), so skip it + continue; + } + + // filter importers only to those which can import into targetType + if ((targetType == null) || (importer.SupportedItemTypes.Any(t => (t == targetType) || targetType.Implements(t)) && importer.CanImportOn(target))) + { + importers.Add(importer); + } + } + + return importers; + } + + public static IEnumerable GetSupportedExportersForItem(this ApplicationCore applicationCore, object itemToExport) + { + var sourceType = itemToExport.GetType(); + + return applicationCore.Plugins.SelectMany(plugin => plugin.GetFileExporters()) + .Where(e => e.SourceTypes().Any(type => type == sourceType || type.IsAssignableFrom(sourceType)) && + e.CanExportFor(itemToExport)); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -rcefa4b33b2ee1f5073bc18d6b769ceaf7c727f66 -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision cefa4b33b2ee1f5073bc18d6b769ceaf7c727f66) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -93,6 +93,7 @@ Properties\GlobalAssembly.cs + Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs =================================================================== diff -u -rb13a656f78f98541b955433ea4074da47b57f8bc -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision b13a656f78f98541b955433ea4074da47b57f8bc) +++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -130,7 +130,7 @@ public bool CanImportToGuiSelection() { - return guiImportHandler.GetImporters(gui.Selection).Any(); + return gui.ApplicationCore.GetImporters(gui.Selection).Any(); } public void ImportOn(object target, IFileImporter importer = null) @@ -302,7 +302,7 @@ private GuiExportHandler CreateGuiExportHandler() { - return new GuiExportHandler(delegate { return gui.ApplicationCore.FileExporters; }, o => gui.DocumentViewsResolver.CreateViewForData(o)); + return new GuiExportHandler(o => gui.ApplicationCore.GetSupportedExportersForItem(o), o => gui.DocumentViewsResolver.CreateViewForData(o)); } private void ApplicationProjectClosing(Project project) Index: Core/Common/src/Core.Common.Gui/GuiExportHandler.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/src/Core.Common.Gui/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Gui/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -34,16 +34,6 @@ GetExporterDialog(exporter, item); } - public IList GetSupportedExportersForItem(object itemToExport) - { - var sourceType = itemToExport.GetType(); - - return FileExportersGetter(itemToExport) - .Where(e => e.SourceTypes().Any(type => type == sourceType || type.IsAssignableFrom(sourceType)) && - e.CanExportFor(itemToExport)) - .ToList(); - } - public void GetExporterDialog(IFileExporter exporter, object selectedItem) { var view = ViewGetter(exporter) as IDialog; @@ -75,20 +65,20 @@ var sourceType = itemToExport.GetType(); var selectExporterDialog = new SelectItemDialog(); - var fileExporters = GetSupportedExportersForItem(itemToExport); + var fileExporters = FileExportersGetter(itemToExport); //if there is only one available exporter use that. - if (fileExporters.Count == 0) + if (!fileExporters.Any()) { MessageBox.Show(Resources.GuiExportHandler_GetSupportedExporterForItemUsingDialog_No_exporter_for_this_item_available); log.Warn(String.Format(Resources.GuiExportHandler_GetSupportedExporterForItemUsingDialog_No_exporter_for_this_item_0_available, sourceType)); return null; } //if there is only one available exporter use that. - if (fileExporters.Count == 1) + if (fileExporters.Count() == 1) { - return fileExporters[0]; + return fileExporters.ElementAt(0); } foreach (var fileExporter in fileExporters) Index: Core/Common/src/Core.Common.Gui/GuiImportHandler.cs =================================================================== diff -u -ra0af742d946a15bead91b315b77086154f1ed15e -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/src/Core.Common.Gui/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision a0af742d946a15bead91b315b77086154f1ed15e) +++ Core/Common/src/Core.Common.Gui/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -45,7 +45,7 @@ { var selectImporterDialog = new SelectItemDialog(); - IList importers = GetImporters(target); + IList importers = gui.ApplicationCore.GetImporters(target); //if there is only one available exporter use that. if (importers.Count == 0) { @@ -77,28 +77,6 @@ return null; } - public IList GetImporters(object target) - { - var targetType = target == null ? null : target.GetType(); - - IList importers = new List(); - foreach (IFileImporter importer in gui.ApplicationCore.FileImporters) - { - if (targetType == null && !importer.CanImportOnRootLevel) - { - //this importer requires something to import into, but we're importing globally (into project or folder), so skip it - continue; - } - - // filter importers only to those which can import into targetType - if ((targetType == null) || (importer.SupportedItemTypes.Any(t => (t == targetType) || targetType.Implements(t)) && importer.CanImportOn(target))) - { - importers.Add(importer); - } - } - return importers; - } - /// /// Typically used after drop action of files from outsite the application /// @@ -111,7 +89,7 @@ Image itemImage = Resources.brick; - IList importers = GetImporters(target); + IList importers = gui.ApplicationCore.GetImporters(target); importers = importers.Where( Index: Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs =================================================================== diff -u -rcaeb44054bb58aa8c480f86e7922a60ecf0f08ef -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision caeb44054bb58aa8c480f86e7922a60ecf0f08ef) +++ Core/Common/test/Core.Common.Integration.Tests/Ringtoets/Application.Ringtoets/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -133,10 +133,8 @@ gui.ApplicationCore = applicationCore; - var guiImportHandler = new GuiImportHandler(gui); + var fileImporters = applicationCore.GetImporters(null); - var fileImporters = guiImportHandler.GetImporters(null); - Assert.AreEqual(1, fileImporters.Count); Assert.AreSame(targetItemImporter2, fileImporters.First()); @@ -185,10 +183,8 @@ gui.ApplicationCore = applicationCore; - var guiImportHandler = new GuiImportHandler(gui); + var fileImporters = applicationCore.GetImporters((long)1.0); - var fileImporters = guiImportHandler.GetImporters((long) 1.0); - Assert.AreEqual(2, fileImporters.Count); mocks.VerifyAll(); @@ -220,10 +216,8 @@ gui.ApplicationCore = applicationCore; - var guiImportHandler = new GuiImportHandler(gui); - //get importers for subtype - var fileImporters = guiImportHandler.GetImporters(new List()); + var fileImporters = applicationCore.GetImporters(new List()); Assert.AreEqual(new[] { @@ -276,10 +270,8 @@ gui.ApplicationCore = applicationCore; - var guiImportHandler = new GuiImportHandler(gui); + var fileImporters = applicationCore.GetImporters((long) 1.0); - var fileImporters = guiImportHandler.GetImporters((long) 1.0); - Assert.AreEqual(1, fileImporters.Count); mocks.VerifyAll(); Index: Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj =================================================================== diff -u -rf5f8af6de6466c42cba57df77748b5e848951490 -rf8109189a1cf9b9905556f12faf82c1035c283a4 --- Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj (.../Core.Common.Tests.csproj) (revision f5f8af6de6466c42cba57df77748b5e848951490) +++ Core/Common/test/Core.Common.Tests/Core.Common.Tests.csproj (.../Core.Common.Tests.csproj) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) @@ -92,7 +92,6 @@ - Fisheye: Tag f8109189a1cf9b9905556f12faf82c1035c283a4 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Tests/Gui/GuiExportHandlerTest.cs'. Fisheye: No comparison available. Pass `N' to diff?