From f3e737720bdd2779f5088437d07264bf4ca3a049 Mon Sep 17 00:00:00 2001 From: Stefan Kip Date: Sun, 23 Jun 2013 16:38:11 +0200 Subject: [PATCH 1/2] Added RemovePropertyGroup method --- src/Umbraco.Core/Models/ContentTypeBase.cs | 9 +++++++++ src/Umbraco.Core/Models/IContentTypeBase.cs | 6 ++++++ src/Umbraco.Core/Models/PropertyGroupCollection.cs | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs index d2fd56f0b6..38676560b1 100644 --- a/src/Umbraco.Core/Models/ContentTypeBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeBase.cs @@ -477,6 +477,15 @@ namespace Umbraco.Core.Models } } + /// + /// Removes a PropertyGroup from the current ContentType + /// + /// Name of the to remove + public void RemovePropertyGroup(string propertyGroupName) + { + PropertyGroups.RemoveItem(propertyGroupName); + } + /// /// Sets the ParentId from the lazy integer id /// diff --git a/src/Umbraco.Core/Models/IContentTypeBase.cs b/src/Umbraco.Core/Models/IContentTypeBase.cs index b0a671eff8..4c3adf83d7 100644 --- a/src/Umbraco.Core/Models/IContentTypeBase.cs +++ b/src/Umbraco.Core/Models/IContentTypeBase.cs @@ -64,6 +64,12 @@ namespace Umbraco.Core.Models /// Alias of the to remove void RemovePropertyType(string propertyTypeAlias); + /// + /// Removes a PropertyGroup from the current ContentType + /// + /// Name of the to remove + void RemovePropertyGroup(string propertyGroupName); + /// /// Sets the ParentId from the lazy integer id /// diff --git a/src/Umbraco.Core/Models/PropertyGroupCollection.cs b/src/Umbraco.Core/Models/PropertyGroupCollection.cs index ee73c3c7ea..facb5b9e5c 100644 --- a/src/Umbraco.Core/Models/PropertyGroupCollection.cs +++ b/src/Umbraco.Core/Models/PropertyGroupCollection.cs @@ -97,6 +97,14 @@ namespace Umbraco.Core.Models return this.Any(x => x.Name == groupName); } + public void RemoveItem(string propertyGroupName) + { + var key = IndexOfKey(propertyGroupName); + //Only removes an item if the key was found + if (key != -1) + RemoveItem(key); + } + public int IndexOfKey(string key) { for (var i = 0; i < this.Count; i++) From d553dfd4b0a8ce5a87690cf7c110b712ce78f650 Mon Sep 17 00:00:00 2001 From: Stefan Kip Date: Sun, 23 Jun 2013 20:24:22 +0200 Subject: [PATCH 2/2] Forgot to update XML comments --- src/Umbraco.Core/Models/ContentTypeBase.cs | 2 +- src/Umbraco.Core/Models/IContentTypeBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs index 38676560b1..aba4ef66a9 100644 --- a/src/Umbraco.Core/Models/ContentTypeBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeBase.cs @@ -480,7 +480,7 @@ namespace Umbraco.Core.Models /// /// Removes a PropertyGroup from the current ContentType /// - /// Name of the to remove + /// Name of the to remove public void RemovePropertyGroup(string propertyGroupName) { PropertyGroups.RemoveItem(propertyGroupName); diff --git a/src/Umbraco.Core/Models/IContentTypeBase.cs b/src/Umbraco.Core/Models/IContentTypeBase.cs index 4c3adf83d7..89fca20b8e 100644 --- a/src/Umbraco.Core/Models/IContentTypeBase.cs +++ b/src/Umbraco.Core/Models/IContentTypeBase.cs @@ -67,7 +67,7 @@ namespace Umbraco.Core.Models /// /// Removes a PropertyGroup from the current ContentType /// - /// Name of the to remove + /// Name of the to remove void RemovePropertyGroup(string propertyGroupName); ///