mirror of https://github.com/ppy/osu
Add type safety to `MatchesOnlineID` extension methods
This commit is contained in:
parent
68e2699043
commit
fbc46941fa
|
@ -62,12 +62,30 @@ public static string GetDisplayString(this object? model)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether the online ID of two instances match.
|
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="instance">The instance to compare.</param>
|
/// <param name="instance">The instance to compare.</param>
|
||||||
/// <param name="other">The other instance to compare against.</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>
|
/// <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)
|
public static bool MatchesOnlineID(this IBeatmapSetInfo? instance, IBeatmapSetInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the online ID of two <see cref="IBeatmapInfo"/>s 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 IBeatmapInfo? instance, IBeatmapInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the online ID of two <see cref="IRulesetInfo"/>s 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 IRulesetInfo? instance, IRulesetInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
private static bool matchesOnlineID(this IHasOnlineID<long>? instance, IHasOnlineID<long>? other)
|
||||||
{
|
{
|
||||||
if (instance == null || other == null)
|
if (instance == null || other == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -78,13 +96,7 @@ public static bool MatchesOnlineID(this IHasOnlineID<long>? instance, IHasOnline
|
||||||
return instance.OnlineID.Equals(other.OnlineID);
|
return instance.OnlineID.Equals(other.OnlineID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static bool matchesOnlineID(this IHasOnlineID<int>? instance, IHasOnlineID<int>? other)
|
||||||
/// 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 == null || other == null)
|
if (instance == null || other == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue