diff --git a/src/Umbraco.Abstractions/Models/IPropertyCollection.cs b/src/Umbraco.Abstractions/Models/IPropertyCollection.cs index ec2c4d90ca..c0a9622e6e 100644 --- a/src/Umbraco.Abstractions/Models/IPropertyCollection.cs +++ b/src/Umbraco.Abstractions/Models/IPropertyCollection.cs @@ -3,19 +3,34 @@ using System.Collections.Specialized; namespace Umbraco.Core.Models { - public interface IPropertyCollection : IEnumerable + public interface IPropertyCollection : IEnumerable, IDeepCloneable, INotifyCollectionChanged { bool TryGetValue(string propertyTypeAlias, out IProperty property); bool Contains(string key); - event NotifyCollectionChangedEventHandler CollectionChanged; - + /// + /// Ensures that the collection contains properties for the specified property types. + /// void EnsurePropertyTypes(IEnumerable propertyTypes); - void EnsureCleanPropertyTypes(IEnumerable propertyTypes); - object DeepClone(); + /// + /// Ensures that the collection does not contain properties not in the specified property types. + /// + void EnsureCleanPropertyTypes(IEnumerable propertyTypes); + + /// + /// Gets the property with the specified alias. + /// IProperty this[string name] { get; } + + /// + /// Gets the property at the specified index. + /// IProperty this[int index] { get; } + + /// + /// Adds or updates a property. + /// void Add(IProperty property); int Count { get; } diff --git a/src/Umbraco.Core/Models/PropertyCollection.cs b/src/Umbraco.Core/Models/PropertyCollection.cs index 4c4d083692..b82fd71eaf 100644 --- a/src/Umbraco.Core/Models/PropertyCollection.cs +++ b/src/Umbraco.Core/Models/PropertyCollection.cs @@ -12,12 +12,10 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class PropertyCollection : KeyedCollection, INotifyCollectionChanged, IDeepCloneable, IPropertyCollection + public class PropertyCollection : KeyedCollection, IPropertyCollection { private readonly object _addLocker = new object(); - internal Func AdditionValidator { get; set; } - /// /// Initializes a new instance of the class. /// @@ -25,16 +23,6 @@ namespace Umbraco.Core.Models : base(StringComparer.InvariantCultureIgnoreCase) { } - /// - /// Initializes a new instance of the class. - /// - /// A function validating added properties. - internal PropertyCollection(Func additionValidator) - : this() - { - AdditionValidator = additionValidator; - } - /// /// Initializes a new instance of the class. /// @@ -47,7 +35,7 @@ namespace Umbraco.Core.Models /// /// Replaces all properties, whilst maintaining validation delegates. /// - internal void Reset(IEnumerable properties) + private void Reset(IEnumerable properties) { //collection events will be raised in each of these calls Clear(); @@ -95,9 +83,7 @@ namespace Umbraco.Core.Models OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } - /// - /// Adds or updates a property. - /// + /// public new void Add(IProperty property) { lock (_addLocker) // TODO: why are we locking here and not everywhere else?! @@ -131,7 +117,7 @@ namespace Umbraco.Core.Models /// /// Gets the index for a specified property alias. /// - public int IndexOfKey(string key) + private int IndexOfKey(string key) { for (var i = 0; i < Count; i++) { @@ -173,9 +159,8 @@ namespace Umbraco.Core.Models CollectionChanged?.Invoke(this, args); } - /// - /// Ensures that the collection contains properties for the specified property types. - /// + + /// public void EnsurePropertyTypes(IEnumerable propertyTypes) { if (propertyTypes == null) @@ -185,9 +170,8 @@ namespace Umbraco.Core.Models Add(new Property(propertyType)); } - /// - /// Ensures that the collection does not contain properties not in the specified property types. - /// + + /// public void EnsureCleanPropertyTypes(IEnumerable propertyTypes) { if (propertyTypes == null)