@@ -77,15 +77,140 @@ public override string Name
77
77
get { return this . hostDetails . Name ; }
78
78
}
79
79
80
+ internal class ConsoleColorProxy
81
+ {
82
+ private EditorServicesPSHostUserInterface _hostUserInterface ;
83
+
84
+ internal ConsoleColorProxy ( EditorServicesPSHostUserInterface hostUserInterface )
85
+ {
86
+ if ( hostUserInterface == null ) throw new ArgumentNullException ( "hostUserInterface" ) ;
87
+ _hostUserInterface = hostUserInterface ;
88
+ }
89
+
90
+ /// <summary>
91
+ /// The ForegroundColor for Error
92
+ /// </summary>
93
+ public ConsoleColor ErrorForegroundColor
94
+ {
95
+ get
96
+ { return _hostUserInterface . ErrorForegroundColor ; }
97
+ set
98
+ { _hostUserInterface . ErrorForegroundColor = value ; }
99
+ }
100
+
101
+ /// <summary>
102
+ /// The BackgroundColor for Error
103
+ /// </summary>
104
+ public ConsoleColor ErrorBackgroundColor
105
+ {
106
+ get
107
+ { return _hostUserInterface . ErrorBackgroundColor ; }
108
+ set
109
+ { _hostUserInterface . ErrorBackgroundColor = value ; }
110
+ }
111
+
112
+ /// <summary>
113
+ /// The ForegroundColor for Warning
114
+ /// </summary>
115
+ public ConsoleColor WarningForegroundColor
116
+ {
117
+ get
118
+ { return _hostUserInterface . WarningForegroundColor ; }
119
+ set
120
+ { _hostUserInterface . WarningForegroundColor = value ; }
121
+ }
122
+
123
+ /// <summary>
124
+ /// The BackgroundColor for Warning
125
+ /// </summary>
126
+ public ConsoleColor WarningBackgroundColor
127
+ {
128
+ get
129
+ { return _hostUserInterface . WarningBackgroundColor ; }
130
+ set
131
+ { _hostUserInterface . WarningBackgroundColor = value ; }
132
+ }
133
+
134
+ /// <summary>
135
+ /// The ForegroundColor for Debug
136
+ /// </summary>
137
+ public ConsoleColor DebugForegroundColor
138
+ {
139
+ get
140
+ { return _hostUserInterface . DebugForegroundColor ; }
141
+ set
142
+ { _hostUserInterface . DebugForegroundColor = value ; }
143
+ }
144
+
145
+ /// <summary>
146
+ /// The BackgroundColor for Debug
147
+ /// </summary>
148
+ public ConsoleColor DebugBackgroundColor
149
+ {
150
+ get
151
+ { return _hostUserInterface . DebugBackgroundColor ; }
152
+ set
153
+ { _hostUserInterface . DebugBackgroundColor = value ; }
154
+ }
155
+
156
+ /// <summary>
157
+ /// The ForegroundColor for Verbose
158
+ /// </summary>
159
+ public ConsoleColor VerboseForegroundColor
160
+ {
161
+ get
162
+ { return _hostUserInterface . VerboseForegroundColor ; }
163
+ set
164
+ { _hostUserInterface . VerboseForegroundColor = value ; }
165
+ }
166
+
167
+ /// <summary>
168
+ /// The BackgroundColor for Verbose
169
+ /// </summary>
170
+ public ConsoleColor VerboseBackgroundColor
171
+ {
172
+ get
173
+ { return _hostUserInterface . VerboseBackgroundColor ; }
174
+ set
175
+ { _hostUserInterface . VerboseBackgroundColor = value ; }
176
+ }
177
+
178
+ /// <summary>
179
+ /// The ForegroundColor for Progress
180
+ /// </summary>
181
+ public ConsoleColor ProgressForegroundColor
182
+ {
183
+ get
184
+ { return _hostUserInterface . ProgressForegroundColor ; }
185
+ set
186
+ { _hostUserInterface . ProgressForegroundColor = value ; }
187
+ }
188
+
189
+ /// <summary>
190
+ /// The BackgroundColor for Progress
191
+ /// </summary>
192
+ public ConsoleColor ProgressBackgroundColor
193
+ {
194
+ get
195
+ { return _hostUserInterface . ProgressBackgroundColor ; }
196
+ set
197
+ { _hostUserInterface . ProgressBackgroundColor = value ; }
198
+ }
199
+ }
200
+
80
201
/// <summary>
81
- ///
202
+ /// Return the actual console host object so that the user can get at
203
+ /// the unproxied methods.
82
204
/// </summary>
83
205
public override PSObject PrivateData
84
206
{
85
- // There is no PrivateData yet but by returning an empty object we can get past PowerShell's
86
- // check for $host.PrivateData["window"] which errors on the null returned by default.
87
- get { return new PSObject ( ) ; }
207
+ get
208
+ {
209
+ if ( hostUserInterface == null ) return null ;
210
+ return _consoleColorProxy ?? ( _consoleColorProxy = PSObject . AsPSObject ( new ConsoleColorProxy ( hostUserInterface ) ) ) ;
211
+ }
88
212
}
213
+ private PSObject _consoleColorProxy ;
89
214
90
215
/// <summary>
91
216
///
0 commit comments