1
- namespace LibGit2Sharp
1
+ using System ;
2
+ using LibGit2Sharp . Core ;
3
+
4
+ namespace LibGit2Sharp
2
5
{
3
6
/// <summary>
4
7
/// A remote repository whose branches are tracked.
5
8
/// </summary>
6
- public class Remote
9
+ public class Remote : IEquatable < Remote >
7
10
{
11
+ private static readonly LambdaEqualityHelper < Remote > equalityHelper =
12
+ new LambdaEqualityHelper < Remote > ( new Func < Remote , object > [ ] { x => x . Name , x => x . Url } ) ;
13
+
8
14
/// <summary>
9
15
/// Gets the alias of this remote repository.
10
16
/// </summary>
@@ -14,5 +20,56 @@ public class Remote
14
20
/// Gets the urls to use to communicate with this remote repository.
15
21
/// </summary>
16
22
public string Url { get ; internal set ; }
23
+
24
+ /// <summary>
25
+ /// Determines whether the specified <see cref = "Object" /> is equal to the current <see cref = "Remote" />.
26
+ /// </summary>
27
+ /// <param name = "obj">The <see cref = "Object" /> to compare with the current <see cref = "Remote" />.</param>
28
+ /// <returns>True if the specified <see cref = "Object" /> is equal to the current <see cref = "Remote" />; otherwise, false.</returns>
29
+ public override bool Equals ( object obj )
30
+ {
31
+ return Equals ( obj as Remote ) ;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Determines whether the specified <see cref = "Remote" /> is equal to the current <see cref = "Remote" />.
36
+ /// </summary>
37
+ /// <param name = "other">The <see cref = "Remote" /> to compare with the current <see cref = "Remote" />.</param>
38
+ /// <returns>True if the specified <see cref = "Remote" /> is equal to the current <see cref = "Remote" />; otherwise, false.</returns>
39
+ public bool Equals ( Remote other )
40
+ {
41
+ return equalityHelper . Equals ( this , other ) ;
42
+ }
43
+
44
+ /// <summary>
45
+ /// Returns the hash code for this instance.
46
+ /// </summary>
47
+ /// <returns>A 32-bit signed integer hash code.</returns>
48
+ public override int GetHashCode ( )
49
+ {
50
+ return equalityHelper . GetHashCode ( this ) ;
51
+ }
52
+
53
+ /// <summary>
54
+ /// Tests if two <see cref = "Remote" /> are equal.
55
+ /// </summary>
56
+ /// <param name = "left">First <see cref = "Remote" /> to compare.</param>
57
+ /// <param name = "right">Second <see cref = "Remote" /> to compare.</param>
58
+ /// <returns>True if the two objects are equal; false otherwise.</returns>
59
+ public static bool operator == ( Remote left , Remote right )
60
+ {
61
+ return Equals ( left , right ) ;
62
+ }
63
+
64
+ /// <summary>
65
+ /// Tests if two <see cref = "Remote" /> are different.
66
+ /// </summary>
67
+ /// <param name = "left">First <see cref = "Remote" /> to compare.</param>
68
+ /// <param name = "right">Second <see cref = "Remote" /> to compare.</param>
69
+ /// <returns>True if the two objects are different; false otherwise.</returns>
70
+ public static bool operator != ( Remote left , Remote right )
71
+ {
72
+ return ! Equals ( left , right ) ;
73
+ }
17
74
}
18
75
}
0 commit comments