diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs index 0b29a90201..da9061fdc6 100644 --- a/src/Umbraco.Core/Models/ContentBase.cs +++ b/src/Umbraco.Core/Models/ContentBase.cs @@ -436,7 +436,7 @@ namespace Umbraco.Core.Models return; } - var propertyType = PropertyTypes.FirstOrDefault(x => x.Alias == propertyTypeAlias); + var propertyType = PropertyTypes.FirstOrDefault(x => x.Alias.InvariantEquals(propertyTypeAlias)); if (propertyType == null) { throw new Exception(String.Format("No PropertyType exists with the supplied alias: {0}", propertyTypeAlias)); diff --git a/src/Umbraco.Core/Models/PropertyCollection.cs b/src/Umbraco.Core/Models/PropertyCollection.cs index 0ff2e13484..2a85a611c9 100644 --- a/src/Umbraco.Core/Models/PropertyCollection.cs +++ b/src/Umbraco.Core/Models/PropertyCollection.cs @@ -21,7 +21,9 @@ namespace Umbraco.Core.Models internal Func ValidateAdd { get; set; } internal PropertyCollection() - {} + : base(StringComparer.InvariantCultureIgnoreCase) + { + } /// /// Initializes a new instance of the class with a delegate responsible for validating the addition of instances. @@ -29,11 +31,13 @@ namespace Umbraco.Core.Models /// The validation callback. /// internal PropertyCollection(Func validationCallback) + : this() { ValidateAdd = validationCallback; } public PropertyCollection(IEnumerable properties) + : this() { Reset(properties); } @@ -113,14 +117,14 @@ namespace Umbraco.Core.Models /// public new bool Contains(string propertyTypeAlias) { - return this.Any(x => x.Alias == propertyTypeAlias); + return base.Contains(propertyTypeAlias); } public int IndexOfKey(string key) { for (var i = 0; i < this.Count; i++) { - if (this[i].Alias == key) + if (this[i].Alias.InvariantEquals(key)) { return i; } @@ -145,7 +149,7 @@ namespace Umbraco.Core.Models { get { - return this.FirstOrDefault(x => x.Alias == propertyType.Alias); + return this.FirstOrDefault(x => x.Alias.InvariantEquals(propertyType.Alias)); } } @@ -165,7 +169,7 @@ namespace Umbraco.Core.Models /// List of PropertyType protected internal void EnsurePropertyTypes(IEnumerable propertyTypes) { - if(/*!this.Any() &&*/ propertyTypes != null) + if (/*!this.Any() &&*/ propertyTypes != null) { foreach (var propertyType in propertyTypes) { @@ -180,7 +184,7 @@ namespace Umbraco.Core.Models /// List of PropertyType protected internal void EnsureCleanPropertyTypes(IEnumerable propertyTypes) { - if(propertyTypes != null) + if (propertyTypes != null) { //Remove PropertyTypes that doesn't exist in the list of new PropertyTypes var aliases = this.Select(p => p.Alias).Except(propertyTypes.Select(x => x.Alias)).ToList();