@@ -8,12 +8,15 @@ namespace LibGit2Sharp
8
8
/// <summary>
9
9
/// A signature
10
10
/// </summary>
11
- public class Signature
11
+ public class Signature : IEquatable < Signature >
12
12
{
13
13
private readonly DateTimeOffset when ;
14
14
private readonly string name ;
15
15
private readonly string email ;
16
16
17
+ private static readonly LambdaEqualityHelper < Signature > equalityHelper =
18
+ new LambdaEqualityHelper < Signature > ( x => x . Name , x => x . Email , x => x . When ) ;
19
+
17
20
internal Signature ( IntPtr signaturePtr )
18
21
{
19
22
var handle = new GitSignature ( ) ;
@@ -65,5 +68,56 @@ public DateTimeOffset When
65
68
{
66
69
get { return when ; }
67
70
}
71
+
72
+ /// <summary>
73
+ /// Determines whether the specified <see cref = "Object" /> is equal to the current <see cref = "Signature" />.
74
+ /// </summary>
75
+ /// <param name = "obj">The <see cref = "Object" /> to compare with the current <see cref = "Signature" />.</param>
76
+ /// <returns>True if the specified <see cref = "Object" /> is equal to the current <see cref = "Signature" />; otherwise, false.</returns>
77
+ public override bool Equals ( object obj )
78
+ {
79
+ return Equals ( obj as Signature ) ;
80
+ }
81
+
82
+ /// <summary>
83
+ /// Determines whether the specified <see cref = "Signature" /> is equal to the current <see cref = "Signature" />.
84
+ /// </summary>
85
+ /// <param name = "other">The <see cref = "Signature" /> to compare with the current <see cref = "Signature" />.</param>
86
+ /// <returns>True if the specified <see cref = "Signature" /> is equal to the current <see cref = "Signature" />; otherwise, false.</returns>
87
+ public bool Equals ( Signature other )
88
+ {
89
+ return equalityHelper . Equals ( this , other ) ;
90
+ }
91
+
92
+ /// <summary>
93
+ /// Returns the hash code for this instance.
94
+ /// </summary>
95
+ /// <returns>A 32-bit signed integer hash code.</returns>
96
+ public override int GetHashCode ( )
97
+ {
98
+ return equalityHelper . GetHashCode ( this ) ;
99
+ }
100
+
101
+ /// <summary>
102
+ /// Tests if two <see cref = "Signature" /> are equal.
103
+ /// </summary>
104
+ /// <param name = "left">First <see cref = "Signature" /> to compare.</param>
105
+ /// <param name = "right">Second <see cref = "Signature" /> to compare.</param>
106
+ /// <returns>True if the two objects are equal; false otherwise.</returns>
107
+ public static bool operator == ( Signature left , Signature right )
108
+ {
109
+ return Equals ( left , right ) ;
110
+ }
111
+
112
+ /// <summary>
113
+ /// Tests if two <see cref = "Signature" /> are different.
114
+ /// </summary>
115
+ /// <param name = "left">First <see cref = "Signature" /> to compare.</param>
116
+ /// <param name = "right">Second <see cref = "Signature" /> to compare.</param>
117
+ /// <returns>True if the two objects are different; false otherwise.</returns>
118
+ public static bool operator != ( Signature left , Signature right )
119
+ {
120
+ return ! Equals ( left , right ) ;
121
+ }
68
122
}
69
123
}
0 commit comments