Skip to content

Commit dbdfc5b

Browse files
author
Dave Wyatt
committed
More code style changes
Based on Microsoft style guidelines, removed _ prefix from private fields and forced use of "this." in all accesses.
1 parent ccdc7b1 commit dbdfc5b

5 files changed

Lines changed: 199 additions & 197 deletions

File tree

Commands/Cmdlets.cs

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,49 @@ namespace PSLogging.Commands
99
[Cmdlet(VerbsCommon.Add, "LogFile")]
1010
public class AddLogFileCommand : PSCmdlet
1111
{
12-
private ScriptBlock _errorCallback;
13-
private LogFile _inputObject;
14-
private string _path;
15-
private StreamType _streams = StreamType.All;
12+
private ScriptBlock errorCallback;
13+
private LogFile inputObject;
14+
private string path;
15+
private StreamType streams = StreamType.All;
1616

1717
#region Parameters
1818

1919
[Parameter(Mandatory = true,
20-
Position = 0,
21-
ParameterSetName = "New")]
20+
Position = 0,
21+
ParameterSetName = "New")]
2222
public string Path
2323
{
24-
get { return _path; }
24+
get { return this.path; }
2525
set
2626
{
27-
_path = System.IO.Path.IsPathRooted(value)
28-
? value
29-
: System.IO.Path.Combine(SessionState.Path.CurrentLocation.Path, value);
27+
this.path = System.IO.Path.IsPathRooted(value)
28+
? value
29+
: System.IO.Path.Combine(this.SessionState.Path.CurrentLocation.Path, value);
3030
}
3131
}
3232

3333
[Parameter(ParameterSetName = "New")]
3434
public StreamType StreamType
3535
{
36-
get { return _streams; }
37-
set { _streams = value; }
36+
get { return this.streams; }
37+
set { this.streams = value; }
3838
}
3939

4040
[Parameter(ParameterSetName = "New")]
4141
public ScriptBlock OnError
4242
{
43-
get { return _errorCallback; }
44-
set { _errorCallback = value; }
43+
get { return this.errorCallback; }
44+
set { this.errorCallback = value; }
4545
}
4646

4747
[Parameter(ParameterSetName = "AttachExisting",
48-
Mandatory = true,
49-
Position = 0,
50-
ValueFromPipeline = true)]
48+
Mandatory = true,
49+
Position = 0,
50+
ValueFromPipeline = true)]
5151
public LogFile InputObject
5252
{
53-
get { return _inputObject; }
54-
set { _inputObject = value; }
53+
get { return this.inputObject; }
54+
set { this.inputObject = value; }
5555
}
5656

5757
#endregion
@@ -60,14 +60,14 @@ protected override void EndProcessing()
6060
{
6161
LogFile logFile;
6262

63-
if (ParameterSetName == "New")
63+
if (this.ParameterSetName == "New")
6464
{
65-
logFile = new LogFile(_path, _streams, _errorCallback);
66-
WriteObject(logFile);
65+
logFile = new LogFile(this.path, this.streams, this.errorCallback);
66+
this.WriteObject(logFile);
6767
}
6868
else
6969
{
70-
logFile = _inputObject;
70+
logFile = this.inputObject;
7171
}
7272

7373
HostIoInterceptor.GetInterceptor().AddSubscriber(logFile);
@@ -77,21 +77,21 @@ protected override void EndProcessing()
7777
[Cmdlet(VerbsCommon.Get, "LogFile")]
7878
public class GetLogFileCommand : PSCmdlet
7979
{
80-
private string _path;
80+
private string path;
8181

8282
[Parameter(Mandatory = false,
83-
Position = 0,
84-
ValueFromPipeline = true,
85-
ValueFromPipelineByPropertyName = true)]
83+
Position = 0,
84+
ValueFromPipeline = true,
85+
ValueFromPipelineByPropertyName = true)]
8686
[ValidateNotNullOrEmpty]
8787
public string Path
8888
{
89-
get { return _path; }
89+
get { return this.path; }
9090
set
9191
{
92-
_path = System.IO.Path.IsPathRooted(value)
93-
? value
94-
: System.IO.Path.Combine(SessionState.Path.CurrentLocation.Path, value);
92+
this.path = System.IO.Path.IsPathRooted(value)
93+
? value
94+
: System.IO.Path.Combine(this.SessionState.Path.CurrentLocation.Path, value);
9595
}
9696
}
9797

@@ -102,9 +102,9 @@ protected override void EndProcessing()
102102
var logFile = subscriber as LogFile;
103103

104104
if (logFile != null &&
105-
(_path == null || System.IO.Path.GetFullPath(logFile.Path) == System.IO.Path.GetFullPath(_path)))
105+
(this.path == null || System.IO.Path.GetFullPath(logFile.Path) == System.IO.Path.GetFullPath(this.path)))
106106
{
107-
WriteObject(logFile);
107+
this.WriteObject(logFile);
108108
}
109109
}
110110
}
@@ -114,13 +114,13 @@ protected override void EndProcessing()
114114
public class DisableLogFileCommand : PSCmdlet
115115
{
116116
[Parameter(Mandatory = true,
117-
ValueFromPipeline = true,
118-
Position = 0)]
117+
ValueFromPipeline = true,
118+
Position = 0)]
119119
public LogFile InputObject { get; set; }
120120

121121
protected override void EndProcessing()
122122
{
123-
HostIoInterceptor.GetInterceptor().RemoveSubscriber(InputObject);
123+
HostIoInterceptor.GetInterceptor().RemoveSubscriber(this.InputObject);
124124
}
125125
} // End DisableLogFileCommand class
126126

@@ -145,58 +145,58 @@ protected override void EndProcessing()
145145
[Cmdlet(VerbsCommon.Add, "OutputSubscriber")]
146146
public class AddOutputSubscriberCommand : PSCmdlet
147147
{
148-
private ScriptBlockOutputSubscriber _inputObject;
149-
private ScriptBlock _onWriteDebug;
150-
private ScriptBlock _onWriteError;
151-
private ScriptBlock _onWriteOutput;
152-
private ScriptBlock _onWriteVerbose;
153-
private ScriptBlock _onWriteWarning;
148+
private ScriptBlockOutputSubscriber inputObject;
149+
private ScriptBlock onWriteDebug;
150+
private ScriptBlock onWriteError;
151+
private ScriptBlock onWriteOutput;
152+
private ScriptBlock onWriteVerbose;
153+
private ScriptBlock onWriteWarning;
154154

155155
#region Parameters
156156

157157
[Parameter(ParameterSetName = "New")]
158158
public ScriptBlock OnWriteOutput
159159
{
160-
get { return _onWriteOutput; }
161-
set { _onWriteOutput = value; }
160+
get { return this.onWriteOutput; }
161+
set { this.onWriteOutput = value; }
162162
}
163163

164164
[Parameter(ParameterSetName = "New")]
165165
public ScriptBlock OnWriteDebug
166166
{
167-
get { return _onWriteDebug; }
168-
set { _onWriteDebug = value; }
167+
get { return this.onWriteDebug; }
168+
set { this.onWriteDebug = value; }
169169
}
170170

171171
[Parameter(ParameterSetName = "New")]
172172
public ScriptBlock OnWriteVerbose
173173
{
174-
get { return _onWriteVerbose; }
175-
set { _onWriteVerbose = value; }
174+
get { return this.onWriteVerbose; }
175+
set { this.onWriteVerbose = value; }
176176
}
177177

178178
[Parameter(ParameterSetName = "New")]
179179
public ScriptBlock OnWriteError
180180
{
181-
get { return _onWriteError; }
182-
set { _onWriteError = value; }
181+
get { return this.onWriteError; }
182+
set { this.onWriteError = value; }
183183
}
184184

185185
[Parameter(ParameterSetName = "New")]
186186
public ScriptBlock OnWriteWarning
187187
{
188-
get { return _onWriteWarning; }
189-
set { _onWriteWarning = value; }
188+
get { return this.onWriteWarning; }
189+
set { this.onWriteWarning = value; }
190190
}
191191

192192
[Parameter(ParameterSetName = "AttachExisting",
193-
Mandatory = true,
194-
ValueFromPipeline = true,
195-
Position = 0)]
193+
Mandatory = true,
194+
ValueFromPipeline = true,
195+
Position = 0)]
196196
public ScriptBlockOutputSubscriber InputObject
197197
{
198-
get { return _inputObject; }
199-
set { _inputObject = value; }
198+
get { return this.inputObject; }
199+
set { this.inputObject = value; }
200200
}
201201

202202
#endregion
@@ -205,18 +205,18 @@ protected override void EndProcessing()
205205
{
206206
ScriptBlockOutputSubscriber subscriber;
207207

208-
if (ParameterSetName == "New")
208+
if (this.ParameterSetName == "New")
209209
{
210-
subscriber = new ScriptBlockOutputSubscriber(_onWriteOutput,
211-
_onWriteDebug,
212-
_onWriteVerbose,
213-
_onWriteError,
214-
_onWriteWarning);
215-
WriteObject(subscriber);
210+
subscriber = new ScriptBlockOutputSubscriber(this.onWriteOutput,
211+
this.onWriteDebug,
212+
this.onWriteVerbose,
213+
this.onWriteError,
214+
this.onWriteWarning);
215+
this.WriteObject(subscriber);
216216
}
217217
else
218218
{
219-
subscriber = _inputObject;
219+
subscriber = this.inputObject;
220220
}
221221

222222
HostIoInterceptor.GetInterceptor().AddSubscriber(subscriber);
@@ -233,7 +233,7 @@ protected override void EndProcessing()
233233
var scriptBlockSubscriber = subscriber as ScriptBlockOutputSubscriber;
234234
if (scriptBlockSubscriber != null)
235235
{
236-
WriteObject(scriptBlockSubscriber);
236+
this.WriteObject(scriptBlockSubscriber);
237237
}
238238
}
239239
}
@@ -243,13 +243,13 @@ protected override void EndProcessing()
243243
public class DisableOutputSubscriberCommand : PSCmdlet
244244
{
245245
[Parameter(Mandatory = true,
246-
ValueFromPipeline = true,
247-
Position = 0)]
246+
ValueFromPipeline = true,
247+
Position = 0)]
248248
public ScriptBlockOutputSubscriber InputObject { get; set; }
249249

250250
protected override void EndProcessing()
251251
{
252-
HostIoInterceptor.GetInterceptor().RemoveSubscriber(InputObject);
252+
HostIoInterceptor.GetInterceptor().RemoveSubscriber(this.InputObject);
253253
}
254254
} // End DisableOutputSubscriberCommand class
255255
}

0 commit comments

Comments
 (0)