Добавили DrawningLinerCompareByType
This commit is contained in:
parent
859a9ffff6
commit
5c7b6d8bf2
@ -60,9 +60,9 @@ namespace ProjectLiner.CollectionGenericObjects
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="airplane">Добавляемый объект</param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(AbstractCompany company, DrawningCommonLiner airplane)
|
||||
public static int operator +(AbstractCompany company, DrawningCommonLiner liner)
|
||||
{
|
||||
return company._collection.Insert(airplane);
|
||||
return company._collection.Insert(liner, new DrawningLinerEqutables() );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLiner.Drawnings;
|
||||
/// <summary>
|
||||
/// Сравнение по типу, скорости, весу
|
||||
/// </summary>
|
||||
public class DrawningLinerCompareByType : IComparer<DrawningCommonLiner?>
|
||||
{
|
||||
|
||||
public int Compare(DrawningCommonLiner? x, DrawningCommonLiner? y)
|
||||
{
|
||||
if (x == null && y == null) return 0;
|
||||
if (x == null || x.EntityCommonLiner == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (y == null || y.EntityCommonLiner == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
}
|
||||
|
||||
var speedCompare = x.EntityCommonLiner.Speed.CompareTo(y.EntityCommonLiner.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
|
||||
return x.EntityCommonLiner.Weight.CompareTo(y.EntityCommonLiner.Weight);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user