This repository was archived by the owner on Feb 3, 2023. It is now read-only.
forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathPackbuilderCallbacks.cs
More file actions
38 lines (33 loc) · 1.49 KB
/
PackbuilderCallbacks.cs
File metadata and controls
38 lines (33 loc) · 1.49 KB
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
36
37
38
using System;
using LibGit2Sharp.Handlers;
namespace LibGit2Sharp.Core
{
internal class PackbuilderCallbacks
{
private readonly PackBuilderProgressHandler onPackBuilderProgress;
/// <summary>S
/// Constructor to set up the native callback given managed delegate.
/// </summary>
/// <param name="onPackBuilderProgress">The <see cref="PackBuilderProgressHandler"/> delegate that the git_packbuilder_progress will call.</param>
internal PackbuilderCallbacks(PackBuilderProgressHandler onPackBuilderProgress)
{
this.onPackBuilderProgress = onPackBuilderProgress;
}
/// <summary>
/// Generates a delegate that matches the native git_packbuilder_progress function's signature and wraps the <see cref="PackBuilderProgressHandler"/> delegate.
/// </summary>
/// <returns>A delegate method with a signature that matches git_transfer_progress_callback.</returns>
internal NativeMethods.git_packbuilder_progress GenerateCallback()
{
if (onPackBuilderProgress == null)
{
return null;
}
return new PackbuilderCallbacks(onPackBuilderProgress).OnGitPackBuilderProgress;
}
private int OnGitPackBuilderProgress(int stage, uint current, uint total, IntPtr payload)
{
return Proxy.ConvertResultToCancelFlag(onPackBuilderProgress((PackBuilderStage)stage, (int)current, (int)total));
}
}
}