From 9bdd080cfbc20d9a8d4e5a615a1ce2703d9d9262 Mon Sep 17 00:00:00 2001 From: Claus Date: Tue, 24 Jan 2017 14:38:22 +0100 Subject: [PATCH] ensuring Udi's are comparable. --- src/Umbraco.Core/Deploy/ArtifactBase.cs | 2 +- src/Umbraco.Core/Udi.cs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Deploy/ArtifactBase.cs b/src/Umbraco.Core/Deploy/ArtifactBase.cs index 4d6bc687cb..d54086fc00 100644 --- a/src/Umbraco.Core/Deploy/ArtifactBase.cs +++ b/src/Umbraco.Core/Deploy/ArtifactBase.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.Deploy throw new ArgumentNullException("udi"); Udi = udi; - Dependencies = dependencies ?? Enumerable.Empty(); + Dependencies = dependencies != null ? dependencies.OrderBy(x => x.Udi) : Enumerable.Empty(); _checksum = new Lazy(GetChecksum); } diff --git a/src/Umbraco.Core/Udi.cs b/src/Umbraco.Core/Udi.cs index 95bd9f90b1..a7298c6f89 100644 --- a/src/Umbraco.Core/Udi.cs +++ b/src/Umbraco.Core/Udi.cs @@ -1,12 +1,8 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Data.Metadata.Edm; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Umbraco.Core.Deploy; -using EntityContainer = System.Data.Metadata.Edm.EntityContainer; namespace Umbraco.Core { @@ -14,7 +10,7 @@ namespace Umbraco.Core /// Represents an entity identifier. /// /// An Udi can be fully qualified or "closed" eg umb://document/{guid} or "open" eg umb://document. - public abstract class Udi + public abstract class Udi : IComparable { private static readonly Dictionary UdiTypes = new Dictionary(); private static readonly ConcurrentDictionary RootUdis = new ConcurrentDictionary(); @@ -76,6 +72,11 @@ namespace Umbraco.Core /// public string EntityType { get; private set; } + public int CompareTo(Udi other) + { + return string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + public override string ToString() { // UriValue is created in the ctor and is never null