diff --git a/src/Umbraco.Core/DictionaryExtensions.cs b/src/Umbraco.Core/DictionaryExtensions.cs
index 194b461fd5..fd6476fe21 100644
--- a/src/Umbraco.Core/DictionaryExtensions.cs
+++ b/src/Umbraco.Core/DictionaryExtensions.cs
@@ -231,7 +231,7 @@ namespace Umbraco.Core
/// The contains key ignore case.
public static bool ContainsKeyIgnoreCase(this IDictionary dictionary, string key)
{
- return dictionary.Keys.Any(i => i.Equals(key, StringComparison.CurrentCultureIgnoreCase));
+ return dictionary.Keys.InvariantContains(key);
}
///
@@ -257,9 +257,9 @@ namespace Umbraco.Core
/// The key.
/// The type
/// The entry
- public static TValue GetEntryIgnoreCase(this IDictionary dictionary, string key)
+ public static TValue GetValueIgnoreCase(this IDictionary dictionary, string key)
{
- return dictionary.GetEntryIgnoreCase(key, default(TValue));
+ return dictionary.GetValueIgnoreCase(key, default(TValue));
}
/// The get entry ignore case.
@@ -268,11 +268,11 @@ namespace Umbraco.Core
/// The default value.
/// The type
/// The entry
- public static TValue GetEntryIgnoreCase(this IDictionary dictionary, string key, TValue defaultValue)
+ public static TValue GetValueIgnoreCase(this IDictionary dictionary, string key, TValue defaultValue)
{
- key = dictionary.Keys.Where(i => i.Equals(key, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
+ key = dictionary.Keys.FirstOrDefault(i => i.InvariantEquals(key));
- return !key.IsNullOrWhiteSpace()
+ return key.IsNullOrWhiteSpace() == false
? dictionary[key]
: defaultValue;
}
diff --git a/src/Umbraco.Core/Models/UmbracoEntityExtensions.cs b/src/Umbraco.Core/Models/UmbracoEntityExtensions.cs
new file mode 100644
index 0000000000..edcc25ade8
--- /dev/null
+++ b/src/Umbraco.Core/Models/UmbracoEntityExtensions.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web.UI.WebControls;
+using Umbraco.Core.Models.EntityBase;
+
+namespace Umbraco.Core.Models
+{
+ internal static class UmbracoEntityExtensions
+ {
+
+ public static object GetAdditionalDataValueIgnoreCase(this IUmbracoEntity entity, string key, object defaultVal)
+ {
+ if (entity.AdditionalData.ContainsKeyIgnoreCase(key) == false) return defaultVal;
+ return entity.AdditionalData.GetValueIgnoreCase(key, defaultVal);
+ }
+
+ public static bool IsContainer(this IUmbracoEntity entity)
+ {
+ if (entity.AdditionalData.ContainsKeyIgnoreCase("IsContainer") == false) return false;
+ var val = entity.AdditionalData.GetValueIgnoreCase("IsContainer", null);
+ if (val is bool && (bool) val)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ }
+}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 471eb1e28a..bf6fcda1e3 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -339,6 +339,7 @@
+
diff --git a/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs b/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs
index 220063c6a0..1d3b5ba33c 100644
--- a/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs
+++ b/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs
@@ -119,8 +119,8 @@ namespace Umbraco.Web.Models.Mapping
// only when creating a new member and we want to have a generated password pre-filled.
Value = new Dictionary
{
- {"generatedPassword", member.AdditionalData.ContainsKey("GeneratedPassword") ? member.AdditionalData["GeneratedPassword"] : null},
- {"newPassword", member.AdditionalData.ContainsKey("NewPassword") ? member.AdditionalData["NewPassword"] : null},
+ {"generatedPassword", member.GetAdditionalDataValueIgnoreCase("GeneratedPassword", null) },
+ {"newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) },
},
//TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor
View = "changepassword",
diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs
index 5fe20fa45b..246cae6ac4 100644
--- a/src/Umbraco.Web/Trees/ContentTreeController.cs
+++ b/src/Umbraco.Web/Trees/ContentTreeController.cs
@@ -98,9 +98,7 @@ namespace Umbraco.Web.Trees
{
//Special check to see if it ia a container, if so then we'll hide children.
- var isContainer = e.AdditionalData.ContainsKey("IsContainer")
- && e.AdditionalData["IsContainer"] is bool
- && (bool)e.AdditionalData["IsContainer"];
+ var isContainer = e.IsContainer();
var node = CreateTreeNode(
e.Id.ToInvariantString(),
diff --git a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs
index d5edd335fd..83bf72d974 100644
--- a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs
+++ b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs
@@ -69,7 +69,7 @@ namespace Umbraco.Web.Trees
protected abstract int UserStartNode { get; }
protected abstract TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings);
-
+
protected abstract MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings);
protected abstract UmbracoObjectTypes UmbracoObjectType { get; }
@@ -88,7 +88,7 @@ namespace Umbraco.Web.Trees
{
//just return their single start node, it will show up under the 'Content' label
var startNode = Services.EntityService.Get(UserStartNode, UmbracoObjectType);
- return new[] {startNode};
+ return new[] { startNode };
}
return Services.EntityService.GetChildren(iid, UmbracoObjectType).ToArray();
@@ -116,8 +116,8 @@ namespace Umbraco.Web.Trees
{
var nodes = new TreeNodeCollection();
var altStartId = string.Empty;
-
- if(queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
+
+ if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
altStartId = queryStrings.GetValue(TreeQueryStringParameters.StartNodeId);
@@ -154,7 +154,7 @@ namespace Umbraco.Web.Trees
// for the time being we'll just load the dashboard of the section.
//queryStrings.GetValue("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin"));
queryStrings.GetValue("application")));
-
+
}
return nodes;
@@ -176,12 +176,12 @@ namespace Umbraco.Web.Trees
{
//before we get the children we need to see if this is a container node
var current = Services.EntityService.Get(int.Parse(id), UmbracoObjectType);
- if (current != null && current.AdditionalData.ContainsKey("IsContainer") && current.AdditionalData["IsContainer"] is bool && (bool)current.AdditionalData["IsContainer"])
+
+ if (current != null && current.IsContainer())
{
//no children!
return new TreeNodeCollection();
}
-
return PerformGetTreeNodes(id, queryStrings);
}
diff --git a/src/Umbraco.Web/Trees/MediaTreeController.cs b/src/Umbraco.Web/Trees/MediaTreeController.cs
index 0f6849c2ad..ea9a5f230e 100644
--- a/src/Umbraco.Web/Trees/MediaTreeController.cs
+++ b/src/Umbraco.Web/Trees/MediaTreeController.cs
@@ -78,9 +78,7 @@ namespace Umbraco.Web.Trees
var entity = (UmbracoEntity)e;
//Special check to see if it ia a container, if so then we'll hide children.
- var isContainer = entity.AdditionalData.ContainsKey("IsContainer")
- && entity.AdditionalData["IsContainer"] is bool
- && (bool)entity.AdditionalData["IsContainer"];
+ var isContainer = entity.IsContainer();
var node = CreateTreeNode(
e.Id.ToInvariantString(),