forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitObjectLazyGroup.cs
More file actions
35 lines (31 loc) · 954 Bytes
/
Copy pathGitObjectLazyGroup.cs
File metadata and controls
35 lines (31 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using LibGit2Sharp.Core.Handles;
namespace LibGit2Sharp.Core
{
internal class GitObjectLazyGroup : LazyGroup<ObjectHandle>
{
private readonly ObjectId id;
public GitObjectLazyGroup(Repository repo, ObjectId id)
: base(repo)
{
this.id = id;
}
protected override void EvaluateInternal(Action<ObjectHandle> evaluator)
{
using (var osw = new ObjectSafeWrapper(id, repo.Handle))
{
evaluator(osw.ObjectPtr);
}
}
public static ILazy<TResult> Singleton<TResult>(Repository repo, ObjectId id, Func<ObjectHandle, TResult> resultSelector)
{
return Singleton(() =>
{
using (var osw = new ObjectSafeWrapper(id, repo.Handle))
{
return resultSelector(osw.ObjectPtr);
}
});
}
}
}