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
/// resolved conflicts.
///
public class IndexReucEntryCollection : IEnumerable
{
private readonly Repository repo;
///
/// Needed for mocking purposes.
///
protected IndexReucEntryCollection()
{ }
internal IndexReucEntryCollection(Repository repo)
{
this.repo = repo;
}
///
/// Gets the with the specified relative path.
///
public virtual IndexReucEntry this[string path]
{
get
{
Ensure.ArgumentNotNullOrEmptyString(path, "path");
IndexReucEntrySafeHandle entryHandle = Proxy.git_index_reuc_get_bypath(repo.Index.Handle, path);
return IndexReucEntry.BuildFromPtr(entryHandle);
}
}
private IndexReucEntry this[int index]
{
get
{
IndexReucEntrySafeHandle entryHandle = Proxy.git_index_reuc_get_byindex(repo.Index.Handle, (UIntPtr)index);
return IndexReucEntry.BuildFromPtr(entryHandle);
}
}
#region IEnumerable Members
private List AllIndexReucs()
{
var list = new List();
int count = Proxy.git_index_reuc_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 AllIndexReucs().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
}
}