66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
|
using DumpTruck.DrawingObjects;
|
|||
|
using DumpTruck.Entities;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace DumpTruck.Generics
|
|||
|
{
|
|||
|
internal class DrawiningCarEqutables : IEqualityComparer<DrawingTruck?>
|
|||
|
{
|
|||
|
public bool Equals(DrawingTruck? x, DrawingTruck? y)
|
|||
|
{
|
|||
|
if (x == null || x.EntityTruck == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(x));
|
|||
|
}
|
|||
|
if (y == null || y.EntityTruck == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(y));
|
|||
|
}
|
|||
|
if (x.GetType().Name != y.GetType().Name)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTruck.Speed != y.EntityTruck.Speed)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTruck.Weight != y.EntityTruck.Weight)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityTruck.BodyColor != y.EntityTruck.BodyColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x is DrawingDumpTruck && y is DrawingDumpTruck)
|
|||
|
{
|
|||
|
EntityDumpTruck xDumpTruck = (EntityDumpTruck)x.EntityTruck;
|
|||
|
EntityDumpTruck yDumpTruck = (EntityDumpTruck)y.EntityTruck;
|
|||
|
|
|||
|
if (xDumpTruck.DumpBoxColor != yDumpTruck.DumpBoxColor)
|
|||
|
return false;
|
|||
|
|
|||
|
if (xDumpTruck.TentColor != yDumpTruck.TentColor)
|
|||
|
return false;
|
|||
|
|
|||
|
if (xDumpTruck.Tent != yDumpTruck.Tent)
|
|||
|
return false;
|
|||
|
|
|||
|
if (xDumpTruck.DumpBox != yDumpTruck.DumpBox)
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
public int GetHashCode([DisallowNull] DrawingTruck obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|