58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using ProjectGasolineTanker.Drawings;
|
|||
|
using ProjectGasolineTanker.Entities;
|
|||
|
|
|||
|
namespace ProjectGasolineTanker.Generics
|
|||
|
{
|
|||
|
internal class DrawingTruckEqutables : 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 DrawingGasolineTanker && y is DrawingGasolineTanker)
|
|||
|
{
|
|||
|
var xGasTruck = (EntityGasolineTanker)x.EntityTruck;
|
|||
|
var yGasTruck = (EntityGasolineTanker)y.EntityTruck;
|
|||
|
|
|||
|
if (xGasTruck.Add_Color != yGasTruck.Add_Color)
|
|||
|
return false;
|
|||
|
|
|||
|
if (xGasTruck.IsTank != yGasTruck.IsTank)
|
|||
|
return false;
|
|||
|
|
|||
|
if (xGasTruck.IsWheel != yGasTruck.IsWheel)
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public int GetHashCode([DisallowNull] DrawingTruck? obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|