diff options
author | Keith Dahlby <dahlbyk@gmail.com> | 2012-10-22 02:23:02 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-10-24 22:04:04 +0400 |
commit | 9f55693d47151a1cef794842b6d34e22cdd8f488 (patch) | |
tree | 3f3572edaddcda8fba144d5b8afd4c657d62a716 /LibGit2Sharp/RepositoryStatus.cs | |
parent | 862f0e946c7d7efa33db688d90b07bb2682009cf (diff) |
Simplify consumption of _foreach methods
Diffstat (limited to 'LibGit2Sharp/RepositoryStatus.cs')
-rw-r--r-- | LibGit2Sharp/RepositoryStatus.cs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs index 54fd8b52..46a297ef 100644 --- a/LibGit2Sharp/RepositoryStatus.cs +++ b/LibGit2Sharp/RepositoryStatus.cs @@ -12,7 +12,7 @@ namespace LibGit2Sharp /// </summary> public class RepositoryStatus : IEnumerable<StatusEntry> { - private readonly List<StatusEntry> statusEntries = new List<StatusEntry>(); + private readonly ICollection<StatusEntry> statusEntries; private readonly List<string> added = new List<string>(); private readonly List<string> staged = new List<string>(); private readonly List<string> removed = new List<string>(); @@ -46,15 +46,14 @@ namespace LibGit2Sharp internal RepositoryStatus(Repository repo) { - Proxy.git_status_foreach(repo.Handle, StateChanged); + statusEntries = Proxy.git_status_foreach(repo.Handle, StateChanged); isDirty = statusEntries.Any(entry => entry.State != FileStatus.Ignored); } - private int StateChanged(IntPtr filePathPtr, uint state, IntPtr payload) + private StatusEntry StateChanged(IntPtr filePathPtr, uint state) { var filePath = FilePathMarshaler.FromNative(filePathPtr); var gitStatus = (FileStatus)state; - statusEntries.Add(new StatusEntry(filePath.Native, gitStatus)); foreach (KeyValuePair<FileStatus, Action<RepositoryStatus, string>> kvp in dispatcher) { @@ -66,7 +65,7 @@ namespace LibGit2Sharp kvp.Value(this, filePath.Native); } - return 0; + return new StatusEntry(filePath.Native, gitStatus); } /// <summary> |