Removed custom equalities from cached objects

This commit is contained in:
RogueException
2016-01-11 20:22:32 -04:00
parent bf0c0fb815
commit 82254ccec4
5 changed files with 4 additions and 18 deletions

View File

@@ -332,11 +332,13 @@ namespace Discord
public Task<Message> SendMessage(string text)
{
if (text == null) throw new ArgumentNullException(nameof(text));
if (text == "") throw new ArgumentException("Value cannot be blank", nameof(text));
return SendMessageInternal(text, false);
}
public Task<Message> SendTTSMessage(string text)
{
if (text == null) throw new ArgumentNullException(nameof(text));
if (text == "") throw new ArgumentException("Value cannot be blank", nameof(text));
return SendMessageInternal(text, true);
}
private async Task<Message> SendMessageInternal(string text, bool isTTS)
@@ -596,8 +598,6 @@ namespace Discord
}
#endregion
public override bool Equals(object obj) => obj is Channel && (obj as Channel).Id == Id;
public override int GetHashCode() => unchecked(Id.GetHashCode() + 5658);
public override string ToString() => Name ?? Id.ToIdString();
}
}

View File

@@ -75,9 +75,6 @@ namespace Discord
}
}
public override bool Equals(object obj)
=> (obj is Profile && (obj as Profile).Id == Id) || (obj is User && (obj as User).Id == Id);
public override int GetHashCode() => unchecked(Id.GetHashCode() + 2061);
public override string ToString() => Id.ToIdString();
}
}

View File

@@ -117,14 +117,7 @@ namespace Discord
try { await Client.ClientAPI.Send(new DeleteRoleRequest(Server.Id, Id)).ConfigureAwait(false); }
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { }
}
public override bool Equals(object obj) => obj is Role && (obj as Role).Id == Id;
public override int GetHashCode() => unchecked(Id.GetHashCode() + 6653);
public override string ToString() => Name ?? Id.ToIdString();
internal object Where(Func<object, bool> p)
{
throw new NotImplementedException();
}
}
}

View File

@@ -498,9 +498,7 @@ namespace Discord
public void RequestOfflineUsers()
=> Client.GatewaySocket.SendRequestMembers(Id, "", 0);
#endregion
public override bool Equals(object obj) => obj is Server && (obj as Server).Id == Id;
public override int GetHashCode() => unchecked(Id.GetHashCode() + 5175);
public override string ToString() => Name ?? Id.ToIdString();
}
}

View File

@@ -338,8 +338,6 @@ namespace Discord
=> Edit(roles: Roles.Except(roles));
#endregion
public override bool Equals(object obj) => obj is User && (obj as User).Id == Id;
public override int GetHashCode() => unchecked(Id.GetHashCode() + 7230);
public override string ToString() => Name != null ? $"{Name}#{Discriminator}" : Id.ToIdString();
}
}