mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:52:54 +08:00
Use generic IComparable together with IEqutable for Message.
This commit is contained in:
parent
12716d2ab4
commit
b9b45493e6
@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
|
||||
[JsonProperty(@"channel_id")]
|
||||
public int Id;
|
||||
|
||||
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
|
||||
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
|
||||
|
||||
//internal bool Joined;
|
||||
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.Chat
|
||||
{
|
||||
public class Message
|
||||
public class Message : IComparable<Message>, IEquatable<Message>
|
||||
{
|
||||
[JsonProperty(@"message_id")]
|
||||
public readonly long Id;
|
||||
@ -42,17 +42,9 @@ namespace osu.Game.Online.Chat
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var objMessage = obj as Message;
|
||||
public int CompareTo(Message other) => Id.CompareTo(other.Id);
|
||||
|
||||
return Id == objMessage?.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
public bool Equals(Message other) => Id == other.Id;
|
||||
}
|
||||
|
||||
public enum TargetType
|
||||
|
Loading…
Reference in New Issue
Block a user