ISEbd-12_Sinelnikova_A.V._S.../ProjectCruiser/Drawnings/DrawiningCruiserEqutables.cs

55 lines
1.3 KiB
C#

using System.Diagnostics.CodeAnalysis;
namespace ProjectCruiser.Drawnings;
/// <summary>
/// Реализация сравнения двух объектов класса-прорисовки
/// </summary>
public class DrawiningCruiserEqutables : IEqualityComparer<DrawningCruiser?>
{
public bool Equals(DrawningCruiser? x, DrawningCruiser? y)
{
if (x == null || x.EntityCruiser == null)
{
return false;
}
if (y == null || y.EntityCruiser == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityCruiser.Speed != y.EntityCruiser.Speed)
{
return false;
}
if (x.EntityCruiser.Weight != y.EntityCruiser.Weight)
{
return false;
}
if (x.EntityCruiser.BodyColor != y.EntityCruiser.BodyColor)
{
return false;
}
if (x is DrawningMilitaryCruiser && y is DrawningMilitaryCruiser)
{
// TODO доделать логику сравнения дополнительных параметров
}
return true;
}
public int GetHashCode([DisallowNull] DrawningCruiser obj)
{
return obj.GetHashCode();
}
}