2024-04-18 01:44:37 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Wino.Core.Domain.Models.MailItem;
|
|
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
namespace Wino.Core.Domain.Models.Comparers;
|
|
|
|
|
|
|
|
|
|
|
|
public class DateComparer : IComparer<IMailItem>, IEqualityComparer
|
2024-04-18 01:44:37 +02:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
public int Compare(IMailItem x, IMailItem y)
|
2025-02-16 11:35:43 +01:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
return DateTime.Compare(y.CreationDate, x.CreationDate);
|
|
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
public new bool Equals(object x, object y)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (x is IMailItem firstItem && y is IMailItem secondItem)
|
2025-02-16 11:43:30 +01:00
|
|
|
|
{
|
2025-02-16 11:54:23 +01:00
|
|
|
|
return firstItem.Equals(secondItem);
|
2025-02-16 11:43:30 +01:00
|
|
|
|
}
|
2025-02-16 11:35:43 +01:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
|
public int GetHashCode(object obj) => (obj as IMailItem).GetHashCode();
|
|
|
|
|
|
|
|
|
|
|
|
public DateComparer()
|
|
|
|
|
|
{
|
2025-02-16 11:43:30 +01:00
|
|
|
|
|
2024-04-18 01:44:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|