diff --git a/WebApi/ExtensionsClassLibrairie/AdministratorExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/AdministratorExtensionMethods.cs index 89c592e..410e359 100644 --- a/WebApi/ExtensionsClassLibrairie/AdministratorExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/AdministratorExtensionMethods.cs @@ -33,25 +33,67 @@ namespace ExtensionsClassLibrairie => a.ToModel().ToEntity(); // equality protocols - public static bool Equals(this Administrator a1, Administrator a2) + public static bool Equals(Administrator a1, Administrator a2) => a1.Username == a2.Username; // reuse other methods - public static bool Equals(this Administrator a1, AdministratorDto a2) - => a1.Equals(a2.ToModel()); - public static bool Equals(this Administrator a1, AdministratorEntity a2) - => a1.Equals(a2.ToModel()); - public static bool Equals(this AdministratorDto a1, Administrator a2) - => a1.ToModel().Equals(a2); - public static bool Equals(this AdministratorDto a1, AdministratorDto a2) - => a1.ToModel().Equals(a2.ToModel()); - public static bool Equals(this AdministratorDto a1, AdministratorEntity a2) - => a1.ToModel().Equals(a2.ToModel()); - public static bool Equals(this AdministratorEntity a1, Administrator a2) - => a1.ToModel().Equals(a2); - public static bool Equals(this AdministratorEntity a1, AdministratorDto a2) - => a1.ToModel().Equals(a2.ToModel()); - public static bool Equals(this AdministratorEntity a1, AdministratorEntity a2) - => a1.ToModel().Equals(a2.ToModel()); + public static bool Equals(Administrator a1, AdministratorDto a2) + => Equals(a1, a2.ToModel()); + public static bool Equals(Administrator a1, AdministratorEntity a2) + => Equals(a1, a2.ToModel()); + public static bool Equals(AdministratorDto a1, Administrator a2) + => Equals(a1.ToModel(), a2); + public static bool Equals(AdministratorDto a1, AdministratorDto a2) + => Equals(a1.ToModel(), a2.ToModel()); + public static bool Equals(AdministratorDto a1, AdministratorEntity a2) + => Equals(a1.ToModel(), a2.ToModel()); + public static bool Equals(AdministratorEntity a1, Administrator a2) + => Equals(a1.ToModel(), a2); + public static bool Equals(AdministratorEntity a1, AdministratorDto a2) + => Equals(a1.ToModel(), a2.ToModel()); + public static bool Equals(AdministratorEntity a1, AdministratorEntity a2) + => Equals(a1.ToModel(), a2.ToModel()); + /// + /// equality protocol for an administrator + /// + /// the administrator + /// an object + /// true if the administrator and the object are sames, false otherwise + public static bool Equals(this Administrator a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Administrator)) return Equals(a, (Administrator)o); + else if (o.GetType() == typeof(AdministratorEntity)) return Equals(a, ((AdministratorEntity)o)); + else if (o.GetType() == typeof(AdministratorDto)) return Equals(a, (AdministratorDto)o); + return false; + } + /// + /// equality protocol for an administrator entity + /// + /// the administrator entity + /// an object + /// true if the administrator entity and the object are sames, false otherwise + public static bool Equals(this AdministratorEntity a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Administrator)) return Equals(a, (Administrator)o); + else if (o.GetType() == typeof(AdministratorEntity)) return Equals(a, ((AdministratorEntity)o)); + else if (o.GetType() == typeof(AdministratorDto)) return Equals(a, (AdministratorDto)o); + return false; + } + /// + /// equality protocol for an administrator dto + /// + /// the administrator dto + /// an object + /// true if the administrator dto and the object are sames, false otherwise + public static bool Equals(this AdministratorDto a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Administrator)) return Equals(a, (Administrator)o); + else if (o.GetType() == typeof(AdministratorEntity)) return Equals(a, ((AdministratorEntity)o)); + else if (o.GetType() == typeof(AdministratorDto)) return Equals(a, (AdministratorDto)o); + return false; + } } } diff --git a/WebApi/ExtensionsClassLibrairie/AnswerExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/AnswerExtensionMethods.cs index 4d7dfd7..9508dc1 100644 --- a/WebApi/ExtensionsClassLibrairie/AnswerExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/AnswerExtensionMethods.cs @@ -53,5 +53,47 @@ namespace ExtensionsClassLibrairie => a1.ToModel().Equals(a2.ToModel()); public static bool Equals(this AnswerEntity a1, AnswerEntity a2) => a1.ToModel().Equals(a2.ToModel()); + /// + /// equality protocol for an answer + /// + /// the answer + /// an object + /// true if the answer and the object are sames, false otherwise + public static bool Equals(this Answer a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Answer)) return Equals(a, (Answer)o); + else if (o.GetType() == typeof(AnswerEntity)) return Equals(a, ((AnswerEntity)o)); + else if (o.GetType() == typeof(AnswerDto)) return Equals(a, (AnswerDto)o); + return false; + } + /// + /// equality protocol for an answer entity + /// + /// the answer entity + /// an object + /// true if the answer entity and the object are sames, false otherwise + public static bool Equals(this AnswerEntity a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Answer)) return Equals(a, (Answer)o); + else if (o.GetType() == typeof(AnswerEntity)) return Equals(a, ((AnswerEntity)o)); + else if (o.GetType() == typeof(AnswerDto)) return Equals(a, (AnswerDto)o); + return false; + } + /// + /// equality protocol for an answer dto + /// + /// the answer dto + /// an object + /// true if the answer dto and the object are sames, false otherwise + public static bool Equals(this AnswerDto a, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Answer)) return Equals(a, (Answer)o); + else if (o.GetType() == typeof(AnswerEntity)) return Equals(a, ((AnswerEntity)o)); + else if (o.GetType() == typeof(AnswerDto)) return Equals(a, (AnswerDto)o); + return false; + } } } diff --git a/WebApi/ExtensionsClassLibrairie/ChapterExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/ChapterExtensionMethods.cs index 3652416..f71ff98 100644 --- a/WebApi/ExtensionsClassLibrairie/ChapterExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/ChapterExtensionMethods.cs @@ -53,5 +53,47 @@ namespace ExtensionsClassLibrairie => c1.ToModel().Equals(c2.ToModel()); public static bool Equals(this ChapterEntity c1, ChapterEntity c2) => c1.ToModel().Equals(c2.ToModel()); + /// + /// equality protocol for a chapter + /// + /// the chapter + /// an object + /// true if the chapter and the object are sames, false otherwise + public static bool Equals(this Chapter c, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Chapter)) return Equals(c, (Chapter)o); + else if (o.GetType() == typeof(ChapterEntity)) return Equals(c, ((ChapterEntity)o)); + else if (o.GetType() == typeof(ChapterDto)) return Equals(c, (ChapterDto)o); + return false; + } + /// + /// equality protocol for a chapter entity + /// + /// the chapter entity + /// an object + /// true if the chapter entity and the object are sames, false otherwise + public static bool Equals(this ChapterEntity c, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Chapter)) return Equals(c, (Chapter)o); + else if (o.GetType() == typeof(ChapterEntity)) return Equals(c, ((ChapterEntity)o)); + else if (o.GetType() == typeof(ChapterDto)) return Equals(c, (ChapterDto)o); + return false; + } + /// + /// equality protocol for a chapter dto + /// + /// the chapter dto + /// an object + /// true if the chapter dto and the object are sames, false otherwise + public static bool Equals(this ChapterDto c, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Chapter)) return Equals(c, (Chapter)o); + else if (o.GetType() == typeof(ChapterEntity)) return Equals(c, ((ChapterEntity)o)); + else if (o.GetType() == typeof(ChapterDto)) return Equals(c, (ChapterDto)o); + return false; + } } } diff --git a/WebApi/ExtensionsClassLibrairie/LobbyExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/LobbyExtensionMethods.cs index ad34f8f..17f1f8b 100644 --- a/WebApi/ExtensionsClassLibrairie/LobbyExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/LobbyExtensionMethods.cs @@ -54,5 +54,47 @@ namespace ExtensionsClassLibrairie => l1.ToModel().Equals(l2.ToModel()); public static bool Equals(this LobbyEntity l1, LobbyEntity l2) => l1.ToModel().Equals(l2.ToModel()); + /// + /// equality protocol for a lobby + /// + /// the lobby + /// an object + /// true if the lobby and the object are sames, false otherwise + public static bool Equals(this Lobby l, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Lobby)) return Equals(l, (Lobby)o); + else if (o.GetType() == typeof(LobbyEntity)) return Equals(l, ((LobbyEntity)o)); + else if (o.GetType() == typeof(LobbyDto)) return Equals(l, (LobbyDto)o); + return false; + } + /// + /// equality protocol for a lobby entity + /// + /// the lobby entity + /// an object + /// true if the lobby entity and the object are sames, false otherwise + public static bool Equals(this LobbyEntity l, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Lobby)) return Equals(l, (Lobby)o); + else if (o.GetType() == typeof(LobbyEntity)) return Equals(l, ((LobbyEntity)o)); + else if (o.GetType() == typeof(LobbyDto)) return Equals(l, (LobbyDto)o); + return false; + } + /// + /// equality protocol for a lobby dto + /// + /// the lobby dto + /// an object + /// true if the lobby dto and the object are sames, false otherwise + public static bool Equals(this LobbyDto l, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Lobby)) return Equals(l, (Lobby)o); + else if (o.GetType() == typeof(LobbyEntity)) return Equals(l, ((LobbyEntity)o)); + else if (o.GetType() == typeof(LobbyDto)) return Equals(l, (LobbyDto)o); + return false; + } } } diff --git a/WebApi/ExtensionsClassLibrairie/PlayerExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/PlayerExtensionMethods.cs index ab9ffa3..3f16cc6 100644 --- a/WebApi/ExtensionsClassLibrairie/PlayerExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/PlayerExtensionMethods.cs @@ -53,5 +53,47 @@ namespace ExtensionsClassLibrairie => p1.ToModel().Equals(p2.ToModel()); public static bool Equals(this PlayerEntity p1, PlayerEntity p2) => p1.ToModel().Equals(p2.ToModel()); + /// + /// equality protocol for a player + /// + /// the player + /// an object + /// true if the player and the object are sames, false otherwise + public static bool Equals(this Player p, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Player)) return Equals(p, (Player)o); + else if (o.GetType() == typeof(PlayerEntity)) return Equals(p, ((PlayerEntity)o)); + else if (o.GetType() == typeof(PlayerDto)) return Equals(p, (PlayerDto)o); + return false; + } + /// + /// equality protocol for a player entity + /// + /// the player entity + /// an object + /// true if the player entity and the object are sames, false otherwise + public static bool Equals(this PlayerEntity p, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Player)) return Equals(p, (Player)o); + else if (o.GetType() == typeof(PlayerEntity)) return Equals(p, ((PlayerEntity)o)); + else if (o.GetType() == typeof(PlayerDto)) return Equals(p, (PlayerDto)o); + return false; + } + /// + /// equality protocol for a player dto + /// + /// the player dto + /// an object + /// true if the player dto and the object are sames, false otherwise + public static bool Equals(this PlayerDto p, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Player)) return Equals(p, (Player)o); + else if (o.GetType() == typeof(PlayerEntity)) return Equals(p, ((PlayerEntity)o)); + else if (o.GetType() == typeof(PlayerDto)) return Equals(p, (PlayerDto)o); + return false; + } } } diff --git a/WebApi/ExtensionsClassLibrairie/QuestionExtensionMethods.cs b/WebApi/ExtensionsClassLibrairie/QuestionExtensionMethods.cs index 82d2659..8d8a8b4 100644 --- a/WebApi/ExtensionsClassLibrairie/QuestionExtensionMethods.cs +++ b/WebApi/ExtensionsClassLibrairie/QuestionExtensionMethods.cs @@ -65,5 +65,47 @@ namespace ExtensionsClassLibrairie => q1.ToModel().Equals(q2.ToModel()); public static bool Equals(this QuestionEntity q1, QuestionEntity q2) => q1.ToModel().Equals(q2.ToModel()); + /// + /// equality protocol for a question + /// + /// the question + /// an object + /// true if the question and the object are sames, false otherwise + public static bool Equals(this Question q, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Question)) return Equals(q, (Question)o); + else if (o.GetType() == typeof(QuestionEntity)) return Equals(q, ((QuestionEntity)o)); + else if (o.GetType() == typeof(QuestionDto)) return Equals(q, (QuestionDto)o); + return false; + } + /// + /// equality protocol for a question entity + /// + /// the question entity + /// an object + /// true if the question entity and the object are sames, false otherwise + public static bool Equals(this QuestionEntity q, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Question)) return Equals(q, (Question)o); + else if (o.GetType() == typeof(QuestionEntity)) return Equals(q, ((QuestionEntity)o)); + else if (o.GetType() == typeof(QuestionDto)) return Equals(q, (QuestionDto)o); + return false; + } + /// + /// equality protocol for a question dto + /// + /// the question dto + /// an object + /// true if the question dto and the object are sames, false otherwise + public static bool Equals(this QuestionDto q, object? o) + { + if (o == null) return false; + if (o.GetType() == typeof(Question)) return Equals(q, (Question)o); + else if (o.GetType() == typeof(QuestionEntity)) return Equals(q, ((QuestionEntity)o)); + else if (o.GetType() == typeof(QuestionDto)) return Equals(q, (QuestionDto)o); + return false; + } } } \ No newline at end of file