Adding Equals() overloads for reactions/emotes (#723)

This commit is contained in:
Pat Murphy
2017-06-29 14:05:16 -07:00
committed by RogueException
parent 032aba9129
commit 224d0403db
3 changed files with 54 additions and 0 deletions

View File

@@ -21,5 +21,18 @@
public string Name { get; }
public override string ToString() => Name;
public override bool Equals(object other)
{
if (other == null) return false;
if (other == this) return true;
var otherEmoji = other as Emoji;
if (otherEmoji == null) return false;
return string.Equals(Name, otherEmoji.Name);
}
public override int GetHashCode() => Name.GetHashCode();
}
}

View File

@@ -25,6 +25,25 @@ namespace Discord
Name = name;
}
public override bool Equals(object other)
{
if (other == null) return false;
if (other == this) return true;
var otherEmote = other as Emote;
if (otherEmote == null) return false;
return string.Equals(Name, otherEmote.Name) && Id == otherEmote.Id;
}
public override int GetHashCode()
{
unchecked
{
return (Name.GetHashCode() * 397) ^ Id.GetHashCode();
}
}
/// <summary>
/// Parse an Emote from its raw format
/// </summary>