Index: Core/Common/src/Core.Common.Base/ApplicationCore.cs =================================================================== diff -u -rf8109189a1cf9b9905556f12faf82c1035c283a4 -rc621c8ee0e3f645a82baedf1654f4d58d1632348 --- Core/Common/src/Core.Common.Base/ApplicationCore.cs (.../ApplicationCore.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) +++ Core/Common/src/Core.Common.Base/ApplicationCore.cs (.../ApplicationCore.cs) (revision c621c8ee0e3f645a82baedf1654f4d58d1632348) @@ -21,7 +21,7 @@ } } - public IEnumerable Plugins + internal IEnumerable Plugins { get { @@ -51,7 +51,7 @@ applicationPlugin.Deactivate(); } - public void Dispose() + public virtual void Dispose() { foreach (var plugin in Plugins.ToList()) { Index: Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs =================================================================== diff -u -rf8109189a1cf9b9905556f12faf82c1035c283a4 -rc621c8ee0e3f645a82baedf1654f4d58d1632348 --- Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs (.../ApplicationCoreExtensions.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) +++ Core/Common/src/Core.Common.Base/ApplicationCoreExtensions.cs (.../ApplicationCoreExtensions.cs) (revision c621c8ee0e3f645a82baedf1654f4d58d1632348) @@ -38,5 +38,12 @@ .Where(e => e.SourceTypes().Any(type => type == sourceType || type.IsAssignableFrom(sourceType)) && e.CanExportFor(itemToExport)); } + + public static IEnumerable GetSupportedDataItemInfos(this ApplicationCore applicationCore, object parent) + { + return applicationCore.Plugins + .SelectMany(p => p.GetDataItemInfos()) + .Where(dataItemInfo => dataItemInfo.AdditionalOwnerCheck == null || dataItemInfo.AdditionalOwnerCheck(parent)); + } } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs =================================================================== diff -u -rf8109189a1cf9b9905556f12faf82c1035c283a4 -rc621c8ee0e3f645a82baedf1654f4d58d1632348 --- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) +++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision c621c8ee0e3f645a82baedf1654f4d58d1632348) @@ -237,7 +237,7 @@ Log.Error(Resources.GuiCommandHandler_AddNewItem_There_needs_to_be_a_project_to_add_an_item); } - var selectDataDialog = CreateSelectionDialogWithItems(GetSupportedDataItemInfos(parent).ToList()); + var selectDataDialog = CreateSelectionDialogWithItems(gui.ApplicationCore.GetSupportedDataItemInfos(parent).ToList()); if (selectDataDialog.ShowDialog(gui.MainWindow as Form) == DialogResult.OK) { @@ -373,16 +373,9 @@ // add more if more cases are found (like a pure wpf case, for example) } - private IEnumerable GetSupportedDataItemInfos(object parent) - { - return gui.ApplicationCore.Plugins - .SelectMany(p => p.GetDataItemInfos()) - .Where(dataItemInfo => dataItemInfo.AdditionalOwnerCheck == null || dataItemInfo.AdditionalOwnerCheck(parent)); - } - private IEnumerable GetSupportedDataItemInfosByValueTypes(object parent, IEnumerable valueTypes) { - return GetSupportedDataItemInfos(parent).Where(dii => valueTypes.Contains(dii.ValueType)); + return gui.ApplicationCore.GetSupportedDataItemInfos(parent).Where(dii => valueTypes.Contains(dii.ValueType)); } private SelectItemDialog CreateSelectionDialogWithItems(IList dataItemInfos) Index: Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs =================================================================== diff -u -rcaeb44054bb58aa8c480f86e7922a60ecf0f08ef -rc621c8ee0e3f645a82baedf1654f4d58d1632348 --- Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs (.../RingtoetsGuiTests.cs) (revision caeb44054bb58aa8c480f86e7922a60ecf0f08ef) +++ Core/Common/test/Core.Common.Tests/Gui/RingtoetsGuiTests.cs (.../RingtoetsGuiTests.cs) (revision c621c8ee0e3f645a82baedf1654f4d58d1632348) @@ -1,7 +1,6 @@ using Core.Common.Base; using Core.Common.Gui; using Core.Common.TestUtils; -using Core.Common.Utils.Collections; using log4net.Core; using NUnit.Framework; using Rhino.Mocks; @@ -44,25 +43,18 @@ { // Setup var mocks = new MockRepository(); - var applicationPlugin = mocks.Stub(); + var applicationCore = mocks.Stub(); + applicationCore.Expect(ac => ac.Dispose()).Repeat.Once(); + mocks.ReplayAll(); - var applicationCore = new ApplicationCore(); - - applicationCore.AddPlugin(applicationPlugin); - gui.ApplicationCore = applicationCore; - // Precondition - Assert.AreEqual(1, applicationCore.Plugins.Count()); - // Call gui.Dispose(); // Assert - Assert.AreEqual(0, applicationCore.Plugins.Count()); - mocks.VerifyAll(); } Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs =================================================================== diff -u -rd121feba5299c86d7ac04a366ee869b163e43ec7 -rc621c8ee0e3f645a82baedf1654f4d58d1632348 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs (.../ProjectTreeView.cs) (revision d121feba5299c86d7ac04a366ee869b163e43ec7) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectTreeView.cs (.../ProjectTreeView.cs) (revision c621c8ee0e3f645a82baedf1654f4d58d1632348) @@ -131,7 +131,7 @@ { buttonFolderAdd.Enabled = true; - buttonFolderAddNewItem.Enabled = applicationCore.Plugins.Any(p => p.GetDataItemInfos().Any()); + buttonFolderAddNewItem.Enabled = applicationCore.GetSupportedDataItemInfos(nodeTag).Any(); buttonFolderDelete.Available = treeView.SelectedNodeCanDelete(); buttonFolderRename.Enabled = treeView.SelectedNodeCanRename();