From 7cf3d18127ab04ab5f46eb927bbfaca8c9697b70 Mon Sep 17 00:00:00 2001 From: Laura Gomez Date: Mon, 28 Oct 2019 18:40:15 -0400 Subject: [PATCH] feat: Adding CompareTo method wich helped with validation cheking on DeploymentTool. --- CHANGELOG.md | 3 +++ ICD.Common.Utils/NullObject.cs | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c54b3..c98ef1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed + - NullObject implements IComparable, fixes issues with null keys in ordered dictionaries + ## [10.0.0] - 2019-10-07 ### Added - IcdEnvironment.GetUtcTime() to get UTC representaiton of current time. diff --git a/ICD.Common.Utils/NullObject.cs b/ICD.Common.Utils/NullObject.cs index 3850f81..ea405c0 100644 --- a/ICD.Common.Utils/NullObject.cs +++ b/ICD.Common.Utils/NullObject.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace ICD.Common.Utils { @@ -6,7 +7,7 @@ namespace ICD.Common.Utils /// Convenience wrapper for supporting null keys in hash tables. /// /// - public struct NullObject : IEquatable> + public struct NullObject : IEquatable>, IComparable> { #region Properties @@ -101,5 +102,20 @@ namespace ICD.Common.Utils } #endregion + + #region Comparable + + public int CompareTo(NullObject other) + { + if (IsNull && other.IsNull) + return 0; + + if (IsNull) + return -1; + + return Comparer.Default.Compare(Item, other.Item); + } + + #endregion } }