using System;
using System.Collections;
using System.Collections.Generic;
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 Index index;
///
/// Needed for mocking purposes.
///
protected IndexReucEntryCollection()
{ }
internal IndexReucEntryCollection(Index index)
{
this.index = index;
}
///
/// Gets the with the specified relative path.
///
public virtual unsafe IndexReucEntry this[string path]
{
get
{
Ensure.ArgumentNotNullOrEmptyString(path, "path");
git_index_reuc_entry* entryHandle = Proxy.git_index_reuc_get_bypath(index.Handle, path);
return IndexReucEntry.BuildFromPtr(entryHandle);
}
}
private unsafe IndexReucEntry this[int idx]
{
get
{
git_index_reuc_entry* entryHandle = Proxy.git_index_reuc_get_byindex(index.Handle, (UIntPtr)idx);
return IndexReucEntry.BuildFromPtr(entryHandle);
}
}
#region IEnumerable Members
private List AllIndexReucs()
{
var list = new List();
int count = Proxy.git_index_reuc_entrycount(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
}
}