forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatusEntry.cs
More file actions
103 lines (91 loc) · 3.79 KB
/
StatusEntry.cs
File metadata and controls
103 lines (91 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Diagnostics;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Holds the calculated status of a particular file at a particular instant.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class StatusEntry : IEquatable<StatusEntry>
{
private readonly string filePath;
private readonly FileStatus state;
private static readonly LambdaEqualityHelper<StatusEntry> equalityHelper =
new LambdaEqualityHelper<StatusEntry>(x => x.FilePath, x => x.State);
/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected StatusEntry()
{ }
internal StatusEntry(string filePath, FileStatus state)
{
this.filePath = filePath;
this.state = state;
}
/// <summary>
/// Gets the <see cref="FileStatus"/> of the file.
/// </summary>
public virtual FileStatus State
{
get { return state; }
}
/// <summary>
/// Gets the relative filepath to the working directory of the file.
/// </summary>
public virtual string FilePath
{
get { return filePath; }
}
/// <summary>
/// Determines whether the specified <see cref = "Object" /> is equal to the current <see cref = "StatusEntry" />.
/// </summary>
/// <param name = "obj">The <see cref = "Object" /> to compare with the current <see cref = "StatusEntry" />.</param>
/// <returns>True if the specified <see cref = "Object" /> is equal to the current <see cref = "StatusEntry" />; otherwise, false.</returns>
public override bool Equals(object obj)
{
return Equals(obj as StatusEntry);
}
/// <summary>
/// Determines whether the specified <see cref = "StatusEntry" /> is equal to the current <see cref = "StatusEntry" />.
/// </summary>
/// <param name = "other">The <see cref = "StatusEntry" /> to compare with the current <see cref = "StatusEntry" />.</param>
/// <returns>True if the specified <see cref = "StatusEntry" /> is equal to the current <see cref = "StatusEntry" />; otherwise, false.</returns>
public bool Equals(StatusEntry 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 = "StatusEntry" /> are equal.
/// </summary>
/// <param name = "left">First <see cref = "StatusEntry" /> to compare.</param>
/// <param name = "right">Second <see cref = "StatusEntry" /> to compare.</param>
/// <returns>True if the two objects are equal; false otherwise.</returns>
public static bool operator ==(StatusEntry left, StatusEntry right)
{
return Equals(left, right);
}
/// <summary>
/// Tests if two <see cref = "StatusEntry" /> are different.
/// </summary>
/// <param name = "left">First <see cref = "StatusEntry" /> to compare.</param>
/// <param name = "right">Second <see cref = "StatusEntry" /> to compare.</param>
/// <returns>True if the two objects are different; false otherwise.</returns>
public static bool operator !=(StatusEntry left, StatusEntry right)
{
return !Equals(left, right);
}
private string DebuggerDisplay
{
get { return string.Format("{0}: {1}", State, FilePath); }
}
}
}