using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using LibGit2Sharp.Core; using LibGit2Sharp.Core.Handles; namespace LibGit2Sharp { /// /// The collection of s in a /// index that reflect the /// original paths of any rename conflicts that exist in the index. /// public class IndexNameEntryCollection : IEnumerable { private readonly Repository repo; /// /// Needed for mocking purposes. /// protected IndexNameEntryCollection() { } internal IndexNameEntryCollection(Repository repo) { this.repo = repo; } private IndexNameEntry this[int index] { get { IndexNameEntrySafeHandle entryHandle = Proxy.git_index_name_get_byindex(repo.Index.Handle, (UIntPtr)index); return IndexNameEntry.BuildFromPtr(entryHandle); } } #region IEnumerable Members private List AllIndexNames() { var list = new List(); int count = Proxy.git_index_name_entrycount(repo.Index.Handle); for (int i = 0; i < count; i++) { list.Add(this[i]); } return list; } /// /// Returns an enumerator that iterates through the collection. /// /// An object that can be used to iterate through the collection. public virtual IEnumerator GetEnumerator() { return AllIndexNames().GetEnumerator(); } /// /// Returns an enumerator that iterates through the collection. /// /// An object that can be used to iterate through the collection. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #endregion } }