mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 01:10:06 +08:00
Improve equality implementations
This commit is contained in:
parent
bb9fa52fda
commit
9474156df4
@ -23,15 +23,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
return Images.SequenceEqual(other.Images);
|
return Images.SequenceEqual(other.Images);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? other) => other is APIMenuContent content && Equals(content);
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
|
|
||||||
if (obj.GetType() != GetType()) return false;
|
|
||||||
|
|
||||||
return Equals((APIMenuContent)obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
|
@ -28,34 +28,27 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
/// The time at which this item should begin displaying. If <c>null</c>, will display immediately.
|
/// The time at which this item should begin displaying. If <c>null</c>, will display immediately.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty(@"begins")]
|
[JsonProperty(@"begins")]
|
||||||
public DateTimeOffset? Begins { get; set; }
|
public DateTimeOffset? Begins { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time at which this item should stop displaying. If <c>null</c>, will display indefinitely.
|
/// The time at which this item should stop displaying. If <c>null</c>, will display indefinitely.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty(@"expires")]
|
[JsonProperty(@"expires")]
|
||||||
public DateTimeOffset? Expires { get; set; }
|
public DateTimeOffset? Expires { get; init; }
|
||||||
|
|
||||||
public bool Equals(APIMenuImage? other)
|
public bool Equals(APIMenuImage? other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
if (ReferenceEquals(null, other)) return false;
|
||||||
if (ReferenceEquals(this, other)) return true;
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
|
||||||
return Image == other.Image && Url == other.Url;
|
return Image == other.Image && Url == other.Url && Begins == other.Begins && Expires == other.Expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? other) => other is APIMenuImage content && Equals(content);
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
if (obj.GetType() != GetType()) return false;
|
|
||||||
|
|
||||||
return Equals((APIMenuImage)obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine(Image, Url);
|
return HashCode.Combine(Image, Url, Begins, Expires);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user