Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-10-27 14:59:55 +0400
committernulltoken <emeric.fermas@gmail.com>2012-10-27 15:25:06 +0400
commitfeed150ec78fa5a66ee2e69824fc57ee35ad69b3 (patch)
treebfd189e286426a64ee04a4c4525114d20ce3ce5c /LibGit2Sharp/Signature.cs
parent8197210f0bc0299fe712d8232a7aea5634b485ce (diff)
Make Signature IEquatable
Diffstat (limited to 'LibGit2Sharp/Signature.cs')
-rw-r--r--LibGit2Sharp/Signature.cs56
1 files changed, 55 insertions, 1 deletions
diff --git a/LibGit2Sharp/Signature.cs b/LibGit2Sharp/Signature.cs
index ac12779e..c7d9bf76 100644
--- a/LibGit2Sharp/Signature.cs
+++ b/LibGit2Sharp/Signature.cs
@@ -8,12 +8,15 @@ namespace LibGit2Sharp
/// <summary>
/// A signature
/// </summary>
- public class Signature
+ public class Signature : IEquatable<Signature>
{
private readonly DateTimeOffset when;
private readonly string name;
private readonly string email;
+ private static readonly LambdaEqualityHelper<Signature> equalityHelper =
+ new LambdaEqualityHelper<Signature>(x => x.Name, x => x.Email, x => x.When);
+
internal Signature(IntPtr signaturePtr)
{
var handle = new GitSignature();
@@ -65,5 +68,56 @@ namespace LibGit2Sharp
{
get { return when; }
}
+
+ /// <summary>
+ /// Determines whether the specified <see cref = "Object" /> is equal to the current <see cref = "Signature" />.
+ /// </summary>
+ /// <param name = "obj">The <see cref = "Object" /> to compare with the current <see cref = "Signature" />.</param>
+ /// <returns>True if the specified <see cref = "Object" /> is equal to the current <see cref = "Signature" />; otherwise, false.</returns>
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as Signature);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref = "Signature" /> is equal to the current <see cref = "Signature" />.
+ /// </summary>
+ /// <param name = "other">The <see cref = "Signature" /> to compare with the current <see cref = "Signature" />.</param>
+ /// <returns>True if the specified <see cref = "Signature" /> is equal to the current <see cref = "Signature" />; otherwise, false.</returns>
+ public bool Equals(Signature other)
+ {
+ return equalityHelper.Equals(this, other);
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>A 32-bit signed integer hash code.</returns>
+ public override int GetHashCode()
+ {
+ return equalityHelper.GetHashCode(this);
+ }
+
+ /// <summary>
+ /// Tests if two <see cref = "Signature" /> are equal.
+ /// </summary>
+ /// <param name = "left">First <see cref = "Signature" /> to compare.</param>
+ /// <param name = "right">Second <see cref = "Signature" /> to compare.</param>
+ /// <returns>True if the two objects are equal; false otherwise.</returns>
+ public static bool operator ==(Signature left, Signature right)
+ {
+ return Equals(left, right);
+ }
+
+ /// <summary>
+ /// Tests if two <see cref = "Signature" /> are different.
+ /// </summary>
+ /// <param name = "left">First <see cref = "Signature" /> to compare.</param>
+ /// <param name = "right">Second <see cref = "Signature" /> to compare.</param>
+ /// <returns>True if the two objects are different; false otherwise.</returns>
+ public static bool operator !=(Signature left, Signature right)
+ {
+ return !Equals(left, right);
+ }
}
}