forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomMshSnapin.cs
More file actions
122 lines (108 loc) · 4.13 KB
/
Copy pathCustomMshSnapin.cs
File metadata and controls
122 lines (108 loc) · 4.13 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
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using Microsoft.Win32;
using System.IO;
using System.Management.Automation.Runspaces;
namespace System.Management.Automation
{
/// <summary>
///
/// Raw mshsnapin is a class for allowing mshsnapin developers to directly
/// specify the set of cmdlets, providers, types, formats, assemblies
/// available in the mshsnapin.
///
/// To use this class, mshsnapin developers will drive from it and fill
/// in details about cmdlet, provider, type, format, assemblies.
///
/// This class will also facilitate the registration of the mshsnapin
/// through installutil.exe.
///
/// This class will be built with monad core engine dll.
/// </summary>
///
/// <remarks>
/// Developers should derive from this class to implement their own
/// custom mshsnapins.
///
/// Derived mshsnapins should be denotated with [RunInstaller] attribute
/// so that installutil.exe can directly install the mshsnapin into registry.
/// </remarks>
public abstract class CustomPSSnapIn : PSSnapInInstaller
{
internal string CustomPSSnapInType
{
get
{
return this.GetType().FullName;
}
}
private Collection<CmdletConfigurationEntry> _cmdlets;
/// <summary>
/// Gets the cmdlets defined in custom mshsnapin.
/// </summary>
/// <remarks>
/// This member can be derived to provide the list of cmdlets to be included for this mshsnapin.
/// </remarks>
public virtual Collection<CmdletConfigurationEntry> Cmdlets
{
get { return _cmdlets ?? (_cmdlets = new Collection<CmdletConfigurationEntry>()); }
}
private Collection<ProviderConfigurationEntry> _providers;
/// <summary>
/// Gets the providers defined in custom mshsnapin.
/// </summary>
/// <remarks>
/// This member can be derived to provide the list of providers to be included for this mshsnapin.
/// </remarks>
public virtual Collection<ProviderConfigurationEntry> Providers
{
get { return _providers ?? (_providers = new Collection<ProviderConfigurationEntry>()); }
}
private Collection<TypeConfigurationEntry> _types;
/// <summary>
/// Gets the types defined in custom mshsnapin.
/// </summary>
/// <remarks>
/// This member can be derived to provide the list of types to be included for this mshsnapin.
/// </remarks>
public virtual Collection<TypeConfigurationEntry> Types
{
get { return _types ?? (_types = new Collection<TypeConfigurationEntry>()); }
}
private Collection<FormatConfigurationEntry> _formats;
/// <summary>
/// Gets the formatsdefined in raw mshsnapin.
/// </summary>
/// <remarks>
/// This member can be derived to provide the list of formats to be included for this mshsnapin.
/// </remarks>
public virtual Collection<FormatConfigurationEntry> Formats
{
get { return _formats ?? (_formats = new Collection<FormatConfigurationEntry>()); }
}
private Dictionary<String, object> _regValues = null;
/// <summary>
///
/// </summary>
internal override Dictionary<String, object> RegValues
{
get
{
if (_regValues == null)
{
_regValues = base.RegValues;
if (!String.IsNullOrEmpty(this.CustomPSSnapInType))
_regValues[RegistryStrings.MshSnapin_CustomPSSnapInType] = this.CustomPSSnapInType;
}
return _regValues;
}
}
}
}