60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using RoadTrain.DrawningObjects;
|
|||
|
using RoadTrain.Entities;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
|
|||
|
namespace RoadTrain.Generics
|
|||
|
{
|
|||
|
internal class DrawiningTrainEqutables : IEqualityComparer<DrawningRoadTrain?>
|
|||
|
{
|
|||
|
public bool Equals(DrawningRoadTrain? x, DrawningRoadTrain? y)
|
|||
|
{
|
|||
|
if (x == null || x.EntityRoadTrain == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(x));
|
|||
|
}
|
|||
|
if (y == null || y.EntityRoadTrain == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(y));
|
|||
|
}
|
|||
|
if (x.GetType().Name != y.GetType().Name)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityRoadTrain.Speed != y.EntityRoadTrain.Speed)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityRoadTrain.Weight != y.EntityRoadTrain.Weight)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x.EntityRoadTrain.BodyColor != y.EntityRoadTrain.BodyColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (x is DrawningTrain && y is DrawningTrain)
|
|||
|
{
|
|||
|
EntityTrain EntityX = x.EntityRoadTrain as EntityTrain;
|
|||
|
EntityTrain EntityY = y.EntityRoadTrain as EntityTrain;
|
|||
|
if (EntityX.WaterContainer != EntityY.WaterContainer)
|
|||
|
return false;
|
|||
|
if (EntityX.SweepingBrush != EntityY.SweepingBrush)
|
|||
|
return false;
|
|||
|
if (EntityX.AdditionalColor != EntityY.AdditionalColor)
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
public int GetHashCode([DisallowNull] DrawningRoadTrain obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|