using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectElectricLocomotive.Drawnings; /// /// Реализация сравнения двух объектов класса-прорисовки /// public class DrawiningLocomotiveEqutables : IEqualityComparer { public bool Equals(DrawningLocomotive? x, DrawningLocomotive? y) { if (x == null || x.EntityLocomotive == null) { return false; } if (y == null || y.EntityLocomotive == null) { return false; } 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 DrawningElectricLocomotive && y is DrawningElectricLocomotive) { // TODO доделать логику сравнения дополнительных параметров } return true; } public int GetHashCode([DisallowNull] DrawningLocomotive obj) { return obj.GetHashCode(); } }