|
|
|
@ -11,23 +11,23 @@ namespace Discord
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an <see cref="IEqualityComparer{T}"/> to be used to compare users.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEqualityComparer<IUser> UserComparer => _userComparer ??= new EntityEqualityComparer<IUser, ulong>();
|
|
|
|
|
public static IEqualityComparer<IUser> UserComparer => _userComparer =_userComparer ?? new EntityEqualityComparer<IUser, ulong>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an <see cref="IEqualityComparer{T}"/> to be used to compare guilds.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEqualityComparer<IGuild> GuildComparer => _guildComparer ??= new EntityEqualityComparer<IGuild, ulong>();
|
|
|
|
|
public static IEqualityComparer<IGuild> GuildComparer => _guildComparer = _guildComparer ?? new EntityEqualityComparer<IGuild, ulong>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an <see cref="IEqualityComparer{T}"/> to be used to compare channels.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEqualityComparer<IChannel> ChannelComparer => _channelComparer ??= new EntityEqualityComparer<IChannel, ulong>();
|
|
|
|
|
public static IEqualityComparer<IChannel> ChannelComparer => _channelComparer = _channelComparer ?? new EntityEqualityComparer<IChannel, ulong>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an <see cref="IEqualityComparer{T}"/> to be used to compare roles.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEqualityComparer<IRole> RoleComparer => _roleComparer ??= new EntityEqualityComparer<IRole, ulong>();
|
|
|
|
|
public static IEqualityComparer<IRole> RoleComparer => _roleComparer = _roleComparer ?? new EntityEqualityComparer<IRole, ulong>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an <see cref="IEqualityComparer{T}"/> to be used to compare messages.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEqualityComparer<IMessage> MessageComparer => _messageComparer ??= new EntityEqualityComparer<IMessage, ulong>();
|
|
|
|
|
public static IEqualityComparer<IMessage> MessageComparer => _messageComparer = _messageComparer ?? new EntityEqualityComparer<IMessage, ulong>();
|
|
|
|
|
|
|
|
|
|
private static IEqualityComparer<IUser> _userComparer;
|
|
|
|
|
private static IEqualityComparer<IGuild> _guildComparer;
|
|
|
|
@ -41,13 +41,11 @@ namespace Discord
|
|
|
|
|
{
|
|
|
|
|
public override bool Equals(TEntity x, TEntity y)
|
|
|
|
|
{
|
|
|
|
|
return (x, y) switch
|
|
|
|
|
{
|
|
|
|
|
(null, null) => true,
|
|
|
|
|
(null, _) => false,
|
|
|
|
|
(_, null) => false,
|
|
|
|
|
var (l, r) => l.Id.Equals(r.Id)
|
|
|
|
|
};
|
|
|
|
|
if (x == null && y == null) return true;
|
|
|
|
|
if (x == null && y != null) return false;
|
|
|
|
|
if (x != null && y == null) return false;
|
|
|
|
|
var tuple = new Tuple<TEntity, TEntity>(x, y);
|
|
|
|
|
return tuple.Item1.Id.Equals(tuple.Item2.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode(TEntity obj)
|
|
|
|
|