@@ -5,7 +5,7 @@ namespace IdGen;
5
5
/// <summary>
6
6
/// Holds information about a decoded id.
7
7
/// </summary>
8
- public struct Id : IEquatable < Id >
8
+ public record struct Id
9
9
{
10
10
/// <summary>
11
11
/// Gets the sequence number of the id.
@@ -35,43 +35,4 @@ internal Id(int sequenceNumber, int generatorId, DateTimeOffset dateTimeOffset)
35
35
GeneratorId = generatorId ;
36
36
DateTimeOffset = dateTimeOffset ;
37
37
}
38
-
39
- /// <summary>
40
- /// Returns a value that indicates whether this instance is equal to a specified object.
41
- /// </summary>
42
- /// <param name="obj">The object to compare with this instance.</param>
43
- /// <returns>true if <paramref name="obj"/> is a <see cref="Id"/> that has the same value as this instance; otherwise, false.</returns>
44
- public override bool Equals ( object obj )
45
- => obj is Id id && Equals ( id ) ;
46
-
47
- /// <summary>
48
- /// Returns the hash code for this instance.
49
- /// </summary>
50
- /// <returns>The hash code for this instance.</returns>
51
- public override int GetHashCode ( ) => Tuple . Create ( DateTimeOffset , GeneratorId , SequenceNumber ) . GetHashCode ( ) ;
52
-
53
- /// <summary>
54
- /// Indicates whether the values of two specified <see cref="Id"/> objects are equal.
55
- /// </summary>
56
- /// <param name="left">The first object to compare.</param>
57
- /// <param name="right">The second object to compare.</param>
58
- /// <returns>true if left and right are equal; otherwise, false.</returns>
59
- public static bool operator == ( Id left , Id right ) => left . Equals ( right ) ;
60
-
61
- /// <summary>
62
- /// Indicates whether the values of two specified <see cref="Id"/> objects are not equal.
63
- /// </summary>
64
- /// <param name="left">The first object to compare.</param>
65
- /// <param name="right">The second object to compare.</param>
66
- /// <returns>true if left and right are not equal; otherwise, false.</returns>
67
- public static bool operator != ( Id left , Id right ) => ! ( left == right ) ;
68
-
69
- /// <summary>
70
- /// Returns a value indicating whether this instance and a specified <see cref="Id"/> object represent the same value.
71
- /// </summary>
72
- /// <param name="other">An <see cref="Id"/> to compare to this instance.</param>
73
- /// <returns>true if <paramref name="other"/> is equal to this instance; otherwise, false.</returns>
74
- public bool Equals ( Id other ) => GeneratorId == other . GeneratorId
75
- && DateTimeOffset == other . DateTimeOffset
76
- && SequenceNumber == other . SequenceNumber ;
77
38
}
0 commit comments