|
1 | 1 | using System; |
2 | | -using System.Collections; |
3 | 2 | using System.Collections.Generic; |
4 | 3 | using System.Globalization; |
5 | 4 | using System.Linq; |
@@ -39,6 +38,27 @@ public NetUser(IPAddress address, DateTime loginTime, string client) |
39 | 38 | /// The client used by this connection. It may be "Unknown" through <see cref="NetHelper"/>, and "Windows NT", "Windows 8", "Windows 7" or "Unknown" through <see cref="AuthHelper"/>. |
40 | 39 | /// </summary> |
41 | 40 | public string Client { get; } |
| 41 | + /// <summary> |
| 42 | + /// Determines whether the two <see cref="NetUser"/> are equal. |
| 43 | + /// </summary> |
| 44 | + /// <param name="obj">The other object.</param> |
| 45 | + /// <returns><see langword="true"/> if they're equal; otherwise, <see langword="false"/>.</returns> |
| 46 | + public override bool Equals(object obj) |
| 47 | + { |
| 48 | + if (obj is NetUser other) |
| 49 | + { |
| 50 | + return Address.Equals(other.Address) && LoginTime == other.LoginTime && Client == other.Client; |
| 51 | + } |
| 52 | + return false; |
| 53 | + } |
| 54 | + /// <summary> |
| 55 | + /// Returns the hash value of this object. |
| 56 | + /// </summary> |
| 57 | + /// <returns>The hash value.</returns> |
| 58 | + public override int GetHashCode() |
| 59 | + { |
| 60 | + return (Address?.GetHashCode() ?? 0) ^ LoginTime.GetHashCode() ^ (Client?.GetHashCode() ?? 0); |
| 61 | + } |
42 | 62 | } |
43 | 63 |
|
44 | 64 | /// <summary> |
@@ -70,6 +90,27 @@ public NetDetail(DateTime login, DateTime logout, long flux) |
70 | 90 | /// The flux has been used. |
71 | 91 | /// </summary> |
72 | 92 | public long Flux { get; } |
| 93 | + /// <summary> |
| 94 | + /// Determines whether the two <see cref="NetDetail"/> are equal. |
| 95 | + /// </summary> |
| 96 | + /// <param name="obj">The other object.</param> |
| 97 | + /// <returns><see langword="true"/> if they're equal; otherwise, <see langword="false"/>.</returns> |
| 98 | + public override bool Equals(object obj) |
| 99 | + { |
| 100 | + if (obj is NetDetail other) |
| 101 | + { |
| 102 | + return LoginTime == other.LoginTime && LogoutTime == other.LogoutTime && Flux == other.Flux; |
| 103 | + } |
| 104 | + return false; |
| 105 | + } |
| 106 | + /// <summary> |
| 107 | + /// Returns the hash value of this object. |
| 108 | + /// </summary> |
| 109 | + /// <returns>The hash value.</returns> |
| 110 | + public override int GetHashCode() |
| 111 | + { |
| 112 | + return LoginTime.GetHashCode() ^ LogoutTime.GetHashCode() ^ Flux.GetHashCode(); |
| 113 | + } |
73 | 114 | } |
74 | 115 |
|
75 | 116 | /// <summary> |
|
0 commit comments