Skip to content

Commit 024b834

Browse files
author
Dave Wyatt
committed
Minor code revisions
1 parent cf506b8 commit 024b834

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

Cmdlets.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public string Path
2929
}
3030
else
3131
{
32-
_path = System.IO.Path.Combine(this.SessionState.Path.CurrentLocation.Path, value);
32+
_path = System.IO.Path.Combine(SessionState.Path.CurrentLocation.Path, value);
3333
}
3434
}
3535
}
@@ -44,8 +44,8 @@ public StreamType StreamType
4444
[Parameter(ParameterSetName = "New")]
4545
public ScriptBlock OnError
4646
{
47-
get { return this._errorCallback; }
48-
set { this._errorCallback = value; }
47+
get { return _errorCallback; }
48+
set { _errorCallback = value; }
4949
}
5050

5151
[Parameter(ParameterSetName = "AttachExisting",
@@ -68,7 +68,7 @@ protected override void EndProcessing()
6868

6969
if (ParameterSetName == "New")
7070
{
71-
logFile = new LogFile(this.Path, _streams, _errorCallback);
71+
logFile = new LogFile(_path, _streams, _errorCallback);
7272
WriteObject(logFile);
7373
}
7474
else
@@ -101,7 +101,7 @@ public string Path
101101
}
102102
else
103103
{
104-
_path = System.IO.Path.Combine(this.SessionState.Path.CurrentLocation.Path, value);
104+
_path = System.IO.Path.Combine(SessionState.Path.CurrentLocation.Path, value);
105105
}
106106
}
107107
}
@@ -133,7 +133,7 @@ public class DisableLogFileCommand : PSCmdlet
133133
protected override void EndProcessing()
134134
{
135135
HostIOInterceptor interceptor = HostIOInterceptor.GetInterceptor();
136-
interceptor.RemoveSubscriber(this.InputObject);
136+
interceptor.RemoveSubscriber(InputObject);
137137
}
138138
} // End DisableLogFileCommand class
139139

@@ -221,7 +221,7 @@ protected override void EndProcessing()
221221

222222
ScriptBlockOutputSubscriber subscriber;
223223

224-
if (this.ParameterSetName == "New")
224+
if (ParameterSetName == "New")
225225
{
226226
subscriber = new ScriptBlockOutputSubscriber(_onWriteOutput, _onWriteDebug, _onWriteVerbose, _onWriteError, _onWriteWarning);
227227
WriteObject(subscriber);
@@ -261,7 +261,7 @@ public class DisableOutputSubscriberCommand : PSCmdlet
261261
protected override void EndProcessing()
262262
{
263263
HostIOInterceptor interceptor = HostIOInterceptor.GetInterceptor();
264-
interceptor.RemoveSubscriber(this.InputObject);
264+
interceptor.RemoveSubscriber(InputObject);
265265
}
266266
} // End DisableOutputSubscriberCommand class
267267
}

LogFile.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public string Path
2727
{
2828
get
2929
{
30-
return System.IO.Path.Combine(this._path, this._fileName);
30+
return System.IO.Path.Combine(_path, _fileName);
3131
}
3232
}
3333

@@ -40,11 +40,11 @@ public string Path
4040

4141
public LogFile(string filename, StreamType streams, ScriptBlock errorCallback)
4242
{
43-
this._fileName = System.IO.Path.GetFileName(filename);
44-
this._path = System.IO.Path.GetDirectoryName(filename);
43+
_fileName = System.IO.Path.GetFileName(filename);
44+
_path = System.IO.Path.GetDirectoryName(filename);
4545

46-
this.Streams = streams;
47-
this.ErrorCallback = errorCallback;
46+
Streams = streams;
47+
ErrorCallback = errorCallback;
4848
}
4949

5050
public LogFile(string filename)
@@ -90,7 +90,7 @@ private void CheckDirectory()
9090

9191
public override void WriteDebug(string message)
9292
{
93-
if ((this.Streams & StreamType.Debug) == StreamType.Debug)
93+
if ((Streams & StreamType.Debug) == StreamType.Debug)
9494
{
9595
try
9696
{
@@ -100,14 +100,14 @@ public override void WriteDebug(string message)
100100
message = String.Format("{0,-29} - [D] {1}", DateTime.Now.ToString(DateTimeFormat), message);
101101
}
102102

103-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
103+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
104104
}
105105
catch (Exception e)
106106
{
107-
if (this.ErrorCallback != null)
107+
if (ErrorCallback != null)
108108
{
109109
HostIOInterceptor.GetInterceptor().Paused = true;
110-
this.ErrorCallback.Invoke(new object[] { this, e });
110+
ErrorCallback.Invoke(new object[] { this, e });
111111
HostIOInterceptor.GetInterceptor().Paused = false;
112112
}
113113
}
@@ -116,7 +116,7 @@ public override void WriteDebug(string message)
116116

117117
public override void WriteError(string message)
118118
{
119-
if ((this.Streams & StreamType.Error) == StreamType.Error)
119+
if ((Streams & StreamType.Error) == StreamType.Error)
120120
{
121121
if (message == null) message = String.Empty;
122122

@@ -128,14 +128,14 @@ public override void WriteError(string message)
128128
message = String.Format("{0,-29} - [E] {1}", DateTime.Now.ToString(DateTimeFormat), message);
129129
}
130130

131-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
131+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
132132
}
133133
catch (Exception e)
134134
{
135-
if (this.ErrorCallback != null)
135+
if (ErrorCallback != null)
136136
{
137137
HostIOInterceptor.GetInterceptor().Paused = true;
138-
this.ErrorCallback.Invoke(new object[] { this, e });
138+
ErrorCallback.Invoke(new object[] { this, e });
139139
HostIOInterceptor.GetInterceptor().Paused = false;
140140
}
141141
}
@@ -144,7 +144,7 @@ public override void WriteError(string message)
144144

145145
public override void WriteOutput(string message)
146146
{
147-
if ((this.Streams & StreamType.Output) == StreamType.Output)
147+
if ((Streams & StreamType.Output) == StreamType.Output)
148148
{
149149
if (message == null) message = String.Empty;
150150

@@ -156,14 +156,14 @@ public override void WriteOutput(string message)
156156
message = String.Format("{0,-29} - {1}", DateTime.Now.ToString(DateTimeFormat), message);
157157
}
158158

159-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
159+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
160160
}
161161
catch (Exception e)
162162
{
163-
if (this.ErrorCallback != null)
163+
if (ErrorCallback != null)
164164
{
165165
HostIOInterceptor.GetInterceptor().Paused = true;
166-
this.ErrorCallback.Invoke(new object[] { this, e });
166+
ErrorCallback.Invoke(new object[] { this, e });
167167
HostIOInterceptor.GetInterceptor().Paused = false;
168168
}
169169
}
@@ -172,7 +172,7 @@ public override void WriteOutput(string message)
172172

173173
public override void WriteHost(string message)
174174
{
175-
if ((this.Streams & StreamType.Output) == StreamType.Output)
175+
if ((Streams & StreamType.Output) == StreamType.Output)
176176
{
177177
if (message == null) message = String.Empty;
178178

@@ -184,14 +184,14 @@ public override void WriteHost(string message)
184184
message = String.Format("{0,-29} - {1}", DateTime.Now.ToString(DateTimeFormat), message);
185185
}
186186

187-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
187+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
188188
}
189189
catch (Exception e)
190190
{
191-
if (this.ErrorCallback != null)
191+
if (ErrorCallback != null)
192192
{
193193
HostIOInterceptor.GetInterceptor().Paused = true;
194-
this.ErrorCallback.Invoke(new object[] { this, e });
194+
ErrorCallback.Invoke(new object[] { this, e });
195195
HostIOInterceptor.GetInterceptor().Paused = false;
196196
}
197197
}
@@ -201,7 +201,7 @@ public override void WriteHost(string message)
201201

202202
public override void WriteVerbose(string message)
203203
{
204-
if ((this.Streams & StreamType.Verbose) == StreamType.Verbose)
204+
if ((Streams & StreamType.Verbose) == StreamType.Verbose)
205205
{
206206
if (message == null) message = String.Empty;
207207

@@ -213,14 +213,14 @@ public override void WriteVerbose(string message)
213213
message = String.Format("{0,-29} - [V] {1}", DateTime.Now.ToString(DateTimeFormat), message);
214214
}
215215

216-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
216+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
217217
}
218218
catch (Exception e)
219219
{
220-
if (this.ErrorCallback != null)
220+
if (ErrorCallback != null)
221221
{
222222
HostIOInterceptor.GetInterceptor().Paused = true;
223-
this.ErrorCallback.Invoke(new object[] { this, e });
223+
ErrorCallback.Invoke(new object[] { this, e });
224224
HostIOInterceptor.GetInterceptor().Paused = false;
225225
}
226226
}
@@ -229,7 +229,7 @@ public override void WriteVerbose(string message)
229229

230230
public override void WriteWarning(string message)
231231
{
232-
if ((this.Streams & StreamType.Warning) == StreamType.Warning)
232+
if ((Streams & StreamType.Warning) == StreamType.Warning)
233233
{
234234
if (message == null) message = String.Empty;
235235

@@ -241,16 +241,16 @@ public override void WriteWarning(string message)
241241
message = String.Format("{0,-29} - [W] {1}", DateTime.Now.ToString(DateTimeFormat), message);
242242
}
243243

244-
File.AppendAllText(System.IO.Path.Combine(this._path, this._fileName), message);
244+
File.AppendAllText(System.IO.Path.Combine(_path, _fileName), message);
245245
}
246246
catch (Exception e)
247247
{
248-
if (this.ErrorCallback != null)
248+
if (ErrorCallback != null)
249249
{
250250
try
251251
{
252252
HostIOInterceptor.GetInterceptor().Paused = true;
253-
this.ErrorCallback.Invoke(new object[] { this, e });
253+
ErrorCallback.Invoke(new object[] { this, e });
254254
HostIOInterceptor.GetInterceptor().Paused = false;
255255
}
256256
catch { }
0 Bytes
Binary file not shown.

ScriptBlockOutputSubscriber.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public ScriptBlockOutputSubscriber(
1818
ScriptBlock onWriteError,
1919
ScriptBlock onWriteWarning)
2020
{
21-
this.OnWriteOutput = onWriteOutput;
22-
this.OnWriteDebug = onWriteDebug;
23-
this.OnWriteVerbose = onWriteVerbose;
24-
this.OnWriteError = onWriteError;
25-
this.OnWriteWarning = onWriteWarning;
21+
OnWriteOutput = onWriteOutput;
22+
OnWriteDebug = onWriteDebug;
23+
OnWriteVerbose = onWriteVerbose;
24+
OnWriteError = onWriteError;
25+
OnWriteWarning = onWriteWarning;
2626
}
2727

2828
public ScriptBlockOutputSubscriber()
@@ -31,32 +31,32 @@ public ScriptBlockOutputSubscriber()
3131

3232
public override void WriteDebug(string message)
3333
{
34-
if (this.OnWriteDebug != null) this.OnWriteDebug.Invoke(new object[] { message });
34+
if (OnWriteDebug != null) OnWriteDebug.Invoke(new object[] { message });
3535
}
3636

3737
public override void WriteOutput(string message)
3838
{
39-
if (this.OnWriteOutput != null) this.OnWriteOutput.Invoke(new object[] { message });
39+
if (OnWriteOutput != null) OnWriteOutput.Invoke(new object[] { message });
4040
}
4141

4242
public override void WriteHost(string message)
4343
{
44-
if (this.OnWriteOutput != null) this.OnWriteOutput.Invoke(new object[] { message });
44+
if (OnWriteOutput != null) OnWriteOutput.Invoke(new object[] { message });
4545
}
4646

4747
public override void WriteError(string message)
4848
{
49-
if (this.OnWriteError != null) this.OnWriteError.Invoke(new object[] { message });
49+
if (OnWriteError != null) OnWriteError.Invoke(new object[] { message });
5050
}
5151

5252
public override void WriteVerbose(string message)
5353
{
54-
if (this.OnWriteVerbose != null) this.OnWriteVerbose.Invoke(new object[] { message });
54+
if (OnWriteVerbose != null) OnWriteVerbose.Invoke(new object[] { message });
5555
}
5656

5757
public override void WriteWarning(string message)
5858
{
59-
if (this.OnWriteWarning != null) this.OnWriteWarning.Invoke(new object[] { message });
59+
if (OnWriteWarning != null) OnWriteWarning.Invoke(new object[] { message });
6060
}
6161
}
6262
}

0 commit comments

Comments
 (0)