56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace ProjectElectricLocomotive.Drawnings;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Реализация сравнения двух объектов класса-прорисовки
|
|||
|
/// </summary>
|
|||
|
public class DrawiningLocomotiveEqutables : IEqualityComparer<DrawningLocomotive?>
|
|||
|
{
|
|||
|
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();
|
|||
|
}
|
|||
|
}
|
|||
|
|