From 70783d4bd1bedc409fd6309fcc2f5940bc918da2 Mon Sep 17 00:00:00 2001 From: Kirill Akulich Date: Fri, 13 Oct 2023 11:36:49 +0300 Subject: [PATCH 1/2] location eq added --- .../Location/LocationModel.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs b/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs index 1b60e3344..11ab68b62 100644 --- a/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs +++ b/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs @@ -1,9 +1,11 @@ // Developed by Softeq Development Corporation // http://www.softeq.com +using System; + namespace Softeq.XToolkit.WhiteLabel.Location { - public class LocationModel + public class LocationModel : IEquatable { public LocationModel() { @@ -17,5 +19,32 @@ public LocationModel(double latitude, double longitude) public double Latitude { get; set; } public double Longitude { get; set; } + + public override bool Equals(object obj) + { + return Equals(obj as LocationModel); + } + + public bool Equals(LocationModel other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return other is LocationModel model && + Latitude == model.Latitude && + Longitude == model.Longitude; + } + + public override int GetHashCode() + { + return HashCode.Combine(Latitude, Longitude); + } } } \ No newline at end of file From ee61471743fc4f380af645754cb7a0116fc23d47 Mon Sep 17 00:00:00 2001 From: Kirill Akulich Date: Mon, 16 Oct 2023 16:28:08 +0300 Subject: [PATCH 2/2] comment fixed --- .../Location/LocationModel.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs b/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs index 11ab68b62..ca19a1e55 100644 --- a/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs +++ b/Softeq.XToolkit.WhiteLabel/Location/LocationModel.cs @@ -25,6 +25,11 @@ public override bool Equals(object obj) return Equals(obj as LocationModel); } + public override int GetHashCode() + { + return HashCode.Combine(Latitude, Longitude); + } + public bool Equals(LocationModel other) { if (ReferenceEquals(null, other)) @@ -37,14 +42,8 @@ public bool Equals(LocationModel other) return true; } - return other is LocationModel model && - Latitude == model.Latitude && - Longitude == model.Longitude; - } - - public override int GetHashCode() - { - return HashCode.Combine(Latitude, Longitude); + return Latitude == other.Latitude && + Longitude == other.Longitude; } } } \ No newline at end of file