diff --git a/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs b/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs index 94e4d6ac..fd511859 100644 --- a/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs +++ b/CSharp/Libraries/UniversalEditor.Core/DataFormatReference.cs @@ -5,7 +5,7 @@ using System.Text; namespace UniversalEditor { - public class DataFormatReference : ReferencedBy + public class DataFormatReference : ReferencedBy, IComparable { public class DataFormatReferenceCollection : System.Collections.ObjectModel.Collection @@ -202,5 +202,31 @@ namespace UniversalEditor if (_referencesByGUID.ContainsKey(guid)) return _referencesByGUID[guid]; return null; } + public override bool Equals(object obj) + { + DataFormatReference omr = (obj as DataFormatReference); + if (omr == null) return false; + if (mvarID == Guid.Empty) + { + // do not compare ID + if (mvarTypeName == null) return false; + return mvarTypeName.Equals(omr.TypeName); + } + return mvarID.Equals(omr.ID); + } + public int CompareTo(DataFormatReference other) + { + if (mvarID == Guid.Empty) + { + // do not compare ID + if (mvarTypeName == null) + { + if (other.ID == Guid.Empty && other.TypeName == null) return 0; + return -1; + } + return mvarTypeName.CompareTo(other.TypeName); + } + return mvarID.CompareTo(other.ID); + } } } diff --git a/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs b/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs index 25788fe8..ff75f0bc 100644 --- a/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs +++ b/CSharp/Libraries/UniversalEditor.Core/ObjectModelReference.cs @@ -5,7 +5,7 @@ using System.Text; namespace UniversalEditor { - public class ObjectModelReference : ReferencedBy + public class ObjectModelReference : ReferencedBy, IComparable { public class ObjectModelReferenceCollection : System.Collections.ObjectModel.Collection @@ -244,5 +244,31 @@ namespace UniversalEditor if (_referencesByGUID.ContainsKey(guid)) return _referencesByGUID[guid]; return null; } + public override bool Equals(object obj) + { + ObjectModelReference omr = (obj as ObjectModelReference); + if (omr == null) return false; + if (mvarID == Guid.Empty) + { + // do not compare ID + if (mvarTypeName == null) return false; + return mvarTypeName.Equals(omr.TypeName); + } + return mvarID.Equals(omr.ID); + } + public int CompareTo(ObjectModelReference other) + { + if (mvarID == Guid.Empty) + { + // do not compare ID + if (mvarTypeName == null) + { + if (other.ID == Guid.Empty && other.TypeName == null) return 0; + return -1; + } + return mvarTypeName.CompareTo(other.TypeName); + } + return mvarID.CompareTo(other.ID); + } } }