forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMshSnapinInstaller.cs
More file actions
159 lines (142 loc) · 4.99 KB
/
Copy pathMshSnapinInstaller.cs
File metadata and controls
159 lines (142 loc) · 4.99 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System.Collections.Generic;
using System.Configuration.Install;
using System.IO;
namespace System.Management.Automation
{
/// <summary>
///
/// MshSnapinBase (or MshSnapinInstaller) is a class for facilitating registry of necessary
/// information for monad mshsnapin's.
///
/// This class will be built with monad core engine dll
/// (System.Management.Automation.dll).
///
/// This is the base class for two kinds of mshsnapins: MshSnapin and CustomMshSnapin.
///
/// Each mshsnapin assembly should derive from this class (indirectly) and fill
/// in information about mshsnapin name, vendor, and version.
///
/// At install time, installation utilities (like InstallUtil.exe) will
/// call install this engine assembly based on the implementation in
/// this class.
///
/// This class derives from base class PSInstaller. PSInstaller will
/// handle the details about how information got written into registry.
/// Here, the information about registry content is provided.
///
/// The reason of not calling this class MshSnapinInstaller is to "hide" the details
/// that MshSnapin class is actually doing installion. It is also more intuitive
/// since people deriving from this class will think there are really
/// implementing a class for mshsnapin.
///
/// </summary>
///
/// <remarks>
/// This is an abstract class to be derived by monad mshsnapin and custom mshsnapin.
/// MshSnapin developer should not directly derive from this class.
/// </remarks>
public abstract class PSSnapInInstaller : PSInstaller
{
/// <summary>
///
/// </summary>
public abstract string Name
{
get;
}
/// <summary>
///
/// </summary>
public abstract string Vendor
{
get;
}
/// <summary>
///
/// </summary>
public virtual string VendorResource
{
get
{
return null;
}
}
/// <summary>
///
/// </summary>
public abstract string Description
{
get;
}
/// <summary>
///
/// </summary>
public virtual string DescriptionResource
{
get
{
return null;
}
}
/// <summary>
///
/// </summary>
private string MshSnapinVersion
{
get
{
return this.GetType().Assembly.GetName().Version.ToString();
}
}
private string _psVersion = null;
/// <summary>
///
/// </summary>
private string PSVersion
{
get { return _psVersion ?? (_psVersion = PSVersionInfo.FeatureVersionString); }
}
/// <summary>
///
/// </summary>
internal sealed override string RegKey
{
get
{
PSSnapInInfo.VerifyPSSnapInFormatThrowIfError(this.Name);
return RegistryStrings.MshSnapinKey + "\\" + Name;
}
}
private Dictionary<String, object> _regValues = null;
/// <summary>
///
/// </summary>
internal override Dictionary<String, object> RegValues
{
get
{
if (_regValues == null)
{
_regValues = new Dictionary<String, object>();
_regValues[RegistryStrings.MshSnapin_MonadVersion] = this.PSVersion;
if (!String.IsNullOrEmpty(this.Vendor))
_regValues[RegistryStrings.MshSnapin_Vendor] = this.Vendor;
if (!String.IsNullOrEmpty(this.Description))
_regValues[RegistryStrings.MshSnapin_Description] = this.Description;
if (!String.IsNullOrEmpty(this.VendorResource))
_regValues[RegistryStrings.MshSnapin_VendorResource] = this.VendorResource;
if (!String.IsNullOrEmpty(this.DescriptionResource))
_regValues[RegistryStrings.MshSnapin_DescriptionResource] = this.DescriptionResource;
_regValues[RegistryStrings.MshSnapin_Version] = this.MshSnapinVersion;
_regValues[RegistryStrings.MshSnapin_ApplicationBase] = Path.GetDirectoryName(this.GetType().Assembly.Location);
_regValues[RegistryStrings.MshSnapin_AssemblyName] = this.GetType().Assembly.FullName;
_regValues[RegistryStrings.MshSnapin_ModuleName] = this.GetType().Assembly.Location;
}
return _regValues;
}
}
}
}