Cleanup
This commit is contained in:
@ -5,12 +5,12 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace UserService.Infrastructure.DataModels
|
||||
{
|
||||
public abstract class Node : ICloneable
|
||||
public abstract class Node : ICloneable, IComparable<Node>
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
[Required] public string CommonName { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
public ICollection<Node> Children { get; set; } = new List<Node>();
|
||||
public ISet<Node> Children { get; set; } = new SortedSet<Node>();
|
||||
public Node? Parent { get; set; } //Parent
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
@ -20,5 +20,14 @@ namespace UserService.Infrastructure.DataModels
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual object Clone() => MemberwiseClone();
|
||||
|
||||
public int CompareTo(Node? other)
|
||||
{
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
if (ReferenceEquals(null, other)) return 1;
|
||||
var commonNameComparison = string.Compare(CommonName, other.CommonName, StringComparison.Ordinal);
|
||||
if (commonNameComparison != 0) return commonNameComparison;
|
||||
return Id.CompareTo(other.Id);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user