ensuring Udi's are comparable.

This commit is contained in:
Claus
2017-01-24 14:38:22 +01:00
parent a3e7153bca
commit 9bdd080cfb
2 changed files with 7 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Core.Deploy
throw new ArgumentNullException("udi");
Udi = udi;
Dependencies = dependencies ?? Enumerable.Empty<ArtifactDependency>();
Dependencies = dependencies != null ? dependencies.OrderBy(x => x.Udi) : Enumerable.Empty<ArtifactDependency>();
_checksum = new Lazy<string>(GetChecksum);
}

View File

@@ -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.
/// </summary>
/// <remarks>An Udi can be fully qualified or "closed" eg umb://document/{guid} or "open" eg umb://document.</remarks>
public abstract class Udi
public abstract class Udi : IComparable<Udi>
{
private static readonly Dictionary<string, UdiType> UdiTypes = new Dictionary<string, UdiType>();
private static readonly ConcurrentDictionary<string, Udi> RootUdis = new ConcurrentDictionary<string, Udi>();
@@ -76,6 +72,11 @@ namespace Umbraco.Core
/// </summary>
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