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 12
Expand file tree
/
Copy pathGlobalSettings.cs
More file actions
73 lines (66 loc) · 2.69 KB
/
Copy pathGlobalSettings.cs
File metadata and controls
73 lines (66 loc) · 2.69 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Global settings for libgit2 and LibGit2Sharp.
/// </summary>
public static class GlobalSettings
{
/// <summary>
/// Returns all the optional features that were compiled into
/// libgit2.
/// </summary>
/// <returns>A <see cref="BuiltInFeatures"/> enumeration.</returns>
public static BuiltInFeatures Features()
{
return Proxy.git_libgit2_features();
}
/// <summary>
/// Registers a new <see cref="SmartSubtransport"/> as a custom
/// smart-protocol transport with libgit2. Any Git remote with
/// the scheme registered will delegate to the given transport
/// for all communication with the server. use this transport to communicate
/// with the server This is not commonly
/// used: some callers may want to re-use an existing connection to
/// perform fetch / push operations to a remote.
///
/// Note that this configuration is global to an entire process
/// and does not honor application domains.
/// </summary>
/// <typeparam name="T">The type of SmartSubtransport to register</typeparam>
/// <param name="scheme">The scheme (eg "http" or "gopher") to register</param>
public static SmartSubtransportRegistration<T> RegisterSmartSubtransport<T>(string scheme)
where T : SmartSubtransport, new()
{
Ensure.ArgumentNotNull(scheme, "scheme");
var registration = new SmartSubtransportRegistration<T>(scheme);
try
{
Proxy.git_transport_register(
registration.Scheme,
registration.FunctionPointer,
registration.RegistrationPointer);
}
catch (Exception)
{
registration.Free();
throw;
}
return registration;
}
/// <summary>
/// Unregisters a previously registered <see cref="SmartSubtransport"/>
/// as a custom smart-protocol transport with libgit2.
/// </summary>
/// <typeparam name="T">The type of SmartSubtransport to register</typeparam>
/// <param name="registration">The previous registration</param>
public static void UnregisterSmartSubtransport<T>(SmartSubtransportRegistration<T> registration)
where T : SmartSubtransport, new()
{
Ensure.ArgumentNotNull(registration, "registration");
Proxy.git_transport_unregister(registration.Scheme);
registration.Free();
}
}
}