Files
Wino-Mail/Wino.Core.Domain/Entities/Shared/AccountContact.cs

66 lines
1.7 KiB
C#
Raw Normal View History

using System;
2024-04-18 01:44:37 +02:00
using System.Collections.Generic;
using SQLite;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Domain.Entities.Shared;
/// <summary>
/// Back storage for simple name-address book.
/// These values will be inserted during MIME fetch.
/// </summary>
// TODO: This can easily evolve to Contact store, just like People app in Windows 10/11.
// Do it.
public class AccountContact : IEquatable<AccountContact>
2024-04-18 01:44:37 +02:00
{
/// <summary>
2025-02-16 11:54:23 +01:00
/// E-mail address of the contact.
2024-04-18 01:44:37 +02:00
/// </summary>
2025-02-16 11:54:23 +01:00
[PrimaryKey]
public string Address { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
/// <summary>
/// Display name of the contact.
/// </summary>
public string Name { get; set; }
2024-08-24 16:06:06 +02:00
2025-02-16 11:54:23 +01:00
/// <summary>
/// Base64 encoded profile image of the contact.
/// </summary>
public string Base64ContactPicture { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
/// <summary>
/// All registered accounts have their contacts registered as root.
/// Root contacts must not be overridden by any configuration.
/// They are created on account creation.
/// </summary>
public bool IsRootContact { get; set; }
2025-02-16 11:54:23 +01:00
public override bool Equals(object obj)
{
return Equals(obj as AccountContact);
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public bool Equals(AccountContact other)
{
return other is not null &&
Address == other.Address &&
Name == other.Name;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override int GetHashCode()
{
return HashCode.Combine(Address, Name);
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public static bool operator ==(AccountContact left, AccountContact right)
{
return EqualityComparer<AccountContact>.Default.Equals(left, right);
}
2025-02-16 11:54:23 +01:00
public static bool operator !=(AccountContact left, AccountContact right)
{
return !(left == right);
2024-04-18 01:44:37 +02:00
}
}