From 50eb60bad23142438a2793ea1e3f0befde87a16e Mon Sep 17 00:00:00 2001 From: Anthony RICHARD Date: Tue, 23 May 2023 14:02:01 +0200 Subject: [PATCH] Correction fonctions equals de la classe Game --- Sources/Stim.Model/Game.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/Stim.Model/Game.cs b/Sources/Stim.Model/Game.cs index 809bcbb..bc9e9c9 100644 --- a/Sources/Stim.Model/Game.cs +++ b/Sources/Stim.Model/Game.cs @@ -6,7 +6,7 @@ using System.Text; namespace Model { [DataContract] - public class Game : INotifyPropertyChanged + public class Game : INotifyPropertyChanged, IEquatable { [DataMember] public string Name @@ -111,8 +111,15 @@ namespace Model public override bool Equals(object? obj) { - if ((obj == null) || !this.GetType().Equals(obj.GetType())) return false; - return Name.Equals(((Game)obj).Name); + if (object.ReferenceEquals(obj, null)) return false; + if (object.ReferenceEquals(this, obj)) return true; + if (this.GetType() != obj.GetType()) return false; + return this.Equals(obj as Game); + } + + public bool Equals(Game? other) + { + return other != null && Name.Equals(other.Name); } public override string ToString()