mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Use extension method to compare online IDs
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
@ -57,5 +58,33 @@ namespace osu.Game.Extensions
|
||||
result ??= model?.ToString() ?? @"null";
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the online ID of two instances match.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to compare.</param>
|
||||
/// <param name="other">The other instance to compare against.</param>
|
||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||
public static bool MatchesOnlineID(this IHasOnlineID<long> instance, IHasOnlineID<long> other)
|
||||
{
|
||||
if (instance.OnlineID < 0 || other.OnlineID < 0)
|
||||
return false;
|
||||
|
||||
return instance.OnlineID.Equals(other.OnlineID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the online ID of two instances match.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to compare.</param>
|
||||
/// <param name="other">The other instance to compare against.</param>
|
||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||
public static bool MatchesOnlineID(this IHasOnlineID<int> instance, IHasOnlineID<int> other)
|
||||
{
|
||||
if (instance.OnlineID < 0 || other.OnlineID < 0)
|
||||
return false;
|
||||
|
||||
return instance.OnlineID.Equals(other.OnlineID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user