-
Notifications
You must be signed in to change notification settings - Fork 924
Expand file tree
/
Copy pathUsernameQueryCredentials.cs
More file actions
31 lines (28 loc) · 1.04 KB
/
UsernameQueryCredentials.cs
File metadata and controls
31 lines (28 loc) · 1.04 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
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Class that holds username query credentials for remote repository access.
/// </summary>
public sealed class UsernameQueryCredentials : Credentials
{
/// <summary>
/// Callback to acquire a credential object.
/// </summary>
/// <param name="cred">The newly created credential object.</param>
/// <returns>0 for success, < 0 to indicate an error, > 0 to indicate no credential was acquired.</returns>
protected internal override int GitCredentialHandler(out IntPtr cred)
{
if (Username == null)
{
throw new InvalidOperationException("UsernameQueryCredentials contains a null Username.");
}
return NativeMethods.git_cred_username_new(out cred, Username);
}
/// <summary>
/// Username for querying the server for supported authentication.
/// </summary>
public string Username { get; set; }
}
}