Files
PIbd-21_SagirovM.M_Liner_Base/Liner/Generics/DrawingLinerEqutables.cs
2023-12-18 16:11:55 +04:00

65 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Liner.Drawing;
using Liner.Entities;
namespace Liner.Generics
{
internal class DrawingLinerEqutables : IEqualityComparer<DrawingLiner?>
{
public bool Equals(DrawingLiner? x, DrawingLiner? y)
{
if (x == null || x.EntityLiner == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y == null || y.EntityLiner == null)
{
throw new ArgumentNullException(nameof(y));
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityLiner.Speed != y.EntityLiner.Speed)
{
return false;
}
if (x.EntityLiner.Weight != y.EntityLiner.Weight)
{
return false;
}
if (x.EntityLiner.BottomColor != y.EntityLiner.BottomColor)
{
return false;
}
if (x is DrawingBigLiner && y is DrawingBigLiner)
{
EntityBigLiner _LinerX = (EntityBigLiner)x.EntityLiner;
EntityBigLiner _LinerY = (EntityBigLiner)y.EntityLiner;
if (_LinerX.SwimmingPool != _LinerY.SwimmingPool)
{
return false;
}
if (_LinerX.Deck != _LinerY.Deck)
{
return false;
}
if (_LinerX.BodyColor != _LinerY.BodyColor)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawingLiner obj)
{
return obj.GetHashCode();
}
}
}