From d0842fc00e29808f81c6b57f8614e42f42c40372 Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 24 Dec 2023 14:25:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20DrawiningLocomo?= =?UTF-8?q?tiveEqutables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawiningLocomotiveEqutables.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ElectricLocomotive/ElectricLocomotive/DrawiningLocomotiveEqutables.cs diff --git a/ElectricLocomotive/ElectricLocomotive/DrawiningLocomotiveEqutables.cs b/ElectricLocomotive/ElectricLocomotive/DrawiningLocomotiveEqutables.cs new file mode 100644 index 0000000..d34be07 --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/DrawiningLocomotiveEqutables.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectElectricLocomotive.DrawingObjects; +using ProjectElectricLocomotive.Entities; +using System.Diagnostics.CodeAnalysis; + +namespace ProjectElectricLocomotive.Generics +{ + internal class DrawingLocomotiveEqutables : IEqualityComparer + { + public bool Equals(DrawingLocomotive? x, DrawingLocomotive? y) + { + if (x == null || x.EntityLocomotive == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityLocomotive == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return false; + } + if (x.EntityLocomotive.Speed != y.EntityLocomotive.Speed) + { + return false; + } + if (x.EntityLocomotive.Weight != y.EntityLocomotive.Weight) + { + return false; + } + if (x.EntityLocomotive.BodyColor != y.EntityLocomotive.BodyColor) + { + return false; + } + if (x is DrawingElectricLocomotive && y is DrawingElectricLocomotive) + { + // TODO доделать логику сравнения дополнительных параметров + } + return true; + } + public int GetHashCode([DisallowNull] DrawingLocomotive obj) + { + return obj.GetHashCode(); + } + } +}