71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
using ProjectBus.Entities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectBus.Drawnings;
|
|
|
|
public class DrawningSimpleBusEquitables : IEqualityComparer<DrawningSimpleBus?>
|
|
{
|
|
public bool Equals(DrawningSimpleBus? x, DrawningSimpleBus? y)
|
|
{
|
|
if (x == null || x.EntitySimpleBus == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (y == null || y.EntitySimpleBus == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.GetType().Name != y.GetType().Name)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.EntitySimpleBus.Speed != y.EntitySimpleBus.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.EntitySimpleBus.Weight != y.EntitySimpleBus.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x.EntitySimpleBus.BodyColor != y.EntitySimpleBus.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (x is DrawningBus && y is DrawningBus)
|
|
{
|
|
EntityBus entityX = (EntityBus)x.EntitySimpleBus;
|
|
EntityBus entityY = (EntityBus)y.EntitySimpleBus;
|
|
if (entityX.AdditionalCompartment != entityY.AdditionalCompartment)
|
|
{
|
|
return false;
|
|
}
|
|
if (entityX.Accordion != entityY.Accordion)
|
|
{
|
|
return false;
|
|
}
|
|
if (entityX.AdditionalColor != entityY.AdditionalColor)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public int GetHashCode([DisallowNull] DrawningSimpleBus obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
}
|
|
}
|