forked from jzoss/Git-Source-Control-Provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProvideSourceControlProvider.cs
110 lines (96 loc) · 3.81 KB
/
ProvideSourceControlProvider.cs
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Globalization;
using MsVsShell = Microsoft.VisualStudio.Shell;
namespace GitScc
{
/// <summary>
/// This attribute registers the source control provider.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideSourceControlProvider : MsVsShell.RegistrationAttribute
{
private string _regName = null;
private string _uiName = null;
/// <summary>
/// </summary>
public ProvideSourceControlProvider(string regName, string uiName)
{
_regName = regName;
_uiName = uiName;
}
/// <summary>
/// Get the friendly name of the provider (written in registry)
/// </summary>
public string RegName
{
get { return _regName; }
}
/// <summary>
/// Get the unique guid identifying the provider
/// </summary>
public Guid RegGuid
{
get { return GuidList.guidSccProvider; }
}
/// <summary>
/// Get the UI name of the provider (string resource ID)
/// </summary>
public string UIName
{
get { return _uiName; }
}
/// <summary>
/// Get the package containing the UI name of the provider
/// </summary>
public Guid UINamePkg
{
get { return GuidList.guidSccProviderPkg; }
}
/// <summary>
/// Get the guid of the provider's service
/// </summary>
public Guid SccProviderService
{
get { return GuidList.guidSccProviderService; }
}
/// <summary>
/// Called to register this attribute with the given context. The context
/// contains the location where the registration inforomation should be placed.
/// It also contains other information such as the type being registered and path information.
/// </summary>
public override void Register(RegistrationContext context)
{
// Write to the context's log what we are about to do
context.Log.WriteLine(String.Format(CultureInfo.CurrentCulture, "BasicSccProvider:\t\t{0}\n", RegName));
// Declare the source control provider, its name, the provider's service
// and aditionally the packages implementing this provider
using (Key sccProviders = context.CreateKey("SourceControlProviders"))
{
using (Key sccProviderKey = sccProviders.CreateSubkey(RegGuid.ToString("B")))
{
sccProviderKey.SetValue("", RegName);
sccProviderKey.SetValue("Service", SccProviderService.ToString("B"));
using (Key sccProviderNameKey = sccProviderKey.CreateSubkey("Name"))
{
sccProviderNameKey.SetValue("", UIName);
sccProviderNameKey.SetValue("Package", UINamePkg.ToString("B"));
sccProviderNameKey.Close();
}
// Additionally, you can create a "Packages" subkey where you can enumerate the dll
// that are used by the source control provider, something like "Package1"="BasicSccProvider.dll"
// but this is not a requirement.
sccProviderKey.Close();
}
sccProviders.Close();
}
}
/// <summary>
/// Unregister the source control provider
/// </summary>
/// <param name="context"></param>
public override void Unregister(RegistrationContext context)
{
context.RemoveKey("SourceControlProviders\\" + GuidList.guidSccProviderPkg.ToString("B"));
}
}
}