diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs
index e79fb933..88103899 100644
--- a/TShockAPI/DB/UserManager.cs
+++ b/TShockAPI/DB/UserManager.cs
@@ -363,7 +363,7 @@ namespace TShockAPI.DB
}
/// A database user.
- public class User
+ public class User : IEquatable
{
/// The database ID of the user.
public int ID { get; set; }
@@ -581,10 +581,66 @@ namespace TShockAPI.DB
return HashPassword(Encoding.UTF8.GetBytes(password));
}
- }
+ #region IEquatable
- /// UserManagerException - An exception generated by the user manager.
- [Serializable]
+ /// Indicates whether the current is equal to another .
+ /// true if the is equal to the parameter; otherwise, false.
+ /// An to compare with this .
+ public bool Equals(User other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return ID == other.ID && string.Equals(Name, other.Name);
+ }
+
+ /// Indicates whether the current is equal to another object.
+ /// true if the is equal to the parameter; otherwise, false.
+ /// An to compare with this .
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != this.GetType()) return false;
+ return Equals((User)obj);
+ }
+
+ /// Serves as the hash function.
+ /// A hash code for the current .
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (ID * 397) ^ (Name != null ? Name.GetHashCode() : 0);
+ }
+ }
+
+ ///
+ /// Compares equality of two objects.
+ ///
+ /// Left hand of the comparison.
+ /// Right hand of the comparison.
+ /// true if the objects are equal; otherwise, false.
+ public static bool operator ==(User left, User right)
+ {
+ return Equals(left, right);
+ }
+
+ ///
+ /// Compares equality of two objects.
+ ///
+ /// Left hand of the comparison.
+ /// Right hand of the comparison.
+ /// true if the objects aren't equal; otherwise, false.
+ public static bool operator !=(User left, User right)
+ {
+ return !Equals(left, right);
+ }
+
+ #endregion
+ }
+
+ /// UserManagerException - An exception generated by the user manager.
+ [Serializable]
public class UserManagerException : Exception
{
/// Creates a new UserManagerException object.