private unsafe TreeEntry(Tree parent, git_tree_entry *nativeEntry) { Ensure.ArgumentNotNull(parent, "parent"); Ensure.ArgumentNotNull(nativeEntry, "nativeEntry"); this.parent = parent; this.nativeEntry = nativeEntry; mode = new LazyNative <FileMode>(() => (FileMode)libgit2.git_tree_entry_filemode(nativeEntry), parent); id = new LazyNative <ObjectId>(() => { git_oid *oid = libgit2.git_tree_entry_id(nativeEntry); Ensure.NativePointerNotNull(oid); return(ObjectId.FromNative(*oid)); }, parent); name = new LazyNative <string>(() => libgit2.git_tree_entry_name(nativeEntry), parent); }
/// <summary> /// Gets the index entry at the specified path. /// </summary> public unsafe TreeEntry this[string name] { get { Ensure.NotDisposed(NativeTree, "tree"); Ensure.ArgumentNotNull(name, "name"); git_tree_entry *entry = libgit2.git_tree_entry_byname(NativeTree, name); GC.KeepAlive(this); if (entry == null) { throw new KeyNotFoundException(string.Format("there is no tree entry for path '{0}'", name)); } return(TreeEntry.FromNative(this, entry)); } }
/// <summary> /// Gets the index entry at the specified index. /// </summary> public unsafe TreeEntry this[int position] { get { Ensure.NotDisposed(NativeTree, "tree"); Ensure.ArgumentConformsTo(() => position >= 0, "position", "position must not be negative"); git_tree_entry *entry = libgit2.git_tree_entry_byindex(NativeTree, (UIntPtr)position); GC.KeepAlive(this); if (entry == null) { throw new IndexOutOfRangeException(string.Format("there is no tree entry at position {0}", position)); } return(TreeEntry.FromNative(this, entry)); } }
internal TreeEntryHandle(git_tree_entry *ptr, bool owned) : base((void *)ptr, owned) { }
internal unsafe static TreeEntry FromNative(Tree parent, git_tree_entry *nativeEntry) { return(new TreeEntry(parent, nativeEntry)); }
public static extern unsafe string git_tree_entry_name(git_tree_entry *entry);
public static extern unsafe git_oid *git_tree_entry_id(git_tree_entry *entry);
public static extern unsafe uint git_tree_entry_filemode(git_tree_entry *entry);