File tree Expand file tree Collapse file tree 11 files changed +18
-71
lines changed
src/Microsoft.PowerShell.Commands.Utility/commands/utility
FormatAndOutput/OutGridView Expand file tree Collapse file tree 11 files changed +18
-71
lines changed Original file line number Diff line number Diff line change @@ -429,10 +429,7 @@ private void CleanUp()
429
429
_readOnlyFileInfo . Attributes |= FileAttributes . ReadOnly ;
430
430
}
431
431
432
- if ( _helper != null )
433
- {
434
- _helper . Dispose ( ) ;
435
- }
432
+ _helper ? . Dispose ( ) ;
436
433
}
437
434
438
435
private void ReconcilePreexistingPropertyNames ( )
Original file line number Diff line number Diff line change @@ -170,10 +170,7 @@ internal void DoneAsStream()
170
170
internal void Stop ( )
171
171
{
172
172
CustomInternalSerializer serializer = _serializer ;
173
- if ( serializer != null )
174
- {
175
- serializer . Stop ( ) ;
176
- }
173
+ serializer ? . Stop ( ) ;
177
174
}
178
175
179
176
#endregion
Original file line number Diff line number Diff line change @@ -236,10 +236,7 @@ protected override void StopProcessing()
236
236
237
237
// Unblock the data collection.
238
238
PSDataCollection < PSStreamObject > debugCollection = _debugBlockingCollection ;
239
- if ( debugCollection != null )
240
- {
241
- debugCollection . Complete ( ) ;
242
- }
239
+ debugCollection ? . Complete ( ) ;
243
240
244
241
// Unblock any new command wait.
245
242
_newRunningScriptEvent . Set ( ) ;
@@ -334,9 +331,8 @@ private void HostWriteLine(string line)
334
331
private void AddDataEventHandlers ( )
335
332
{
336
333
// Create new collection objects.
337
- if ( _debugBlockingCollection != null ) { _debugBlockingCollection . Dispose ( ) ; }
338
-
339
- if ( _debugAccumulateCollection != null ) { _debugAccumulateCollection . Dispose ( ) ; }
334
+ _debugBlockingCollection ? . Dispose ( ) ;
335
+ _debugAccumulateCollection ? . Dispose ( ) ;
340
336
341
337
_debugBlockingCollection = new PSDataCollection < PSStreamObject > ( ) ;
342
338
_debugBlockingCollection . BlockingEnumerator = true ;
Original file line number Diff line number Diff line change @@ -291,8 +291,7 @@ protected override void EndProcessing()
291
291
line = GetAliasLine ( alias , "set-alias -Name:\" {0}\" -Value:\" {1}\" -Description:\" {2}\" -Option:\" {3}\" " ) ;
292
292
}
293
293
294
- if ( writer != null )
295
- writer . WriteLine ( line ) ;
294
+ writer ? . WriteLine ( line ) ;
296
295
297
296
if ( PassThru )
298
297
{
@@ -302,8 +301,7 @@ protected override void EndProcessing()
302
301
}
303
302
finally
304
303
{
305
- if ( writer != null )
306
- writer . Dispose ( ) ;
304
+ writer ? . Dispose ( ) ;
307
305
// reset the read-only attribute
308
306
if ( readOnlyFileInfo != null )
309
307
readOnlyFileInfo . Attributes |= FileAttributes . ReadOnly ;
Original file line number Diff line number Diff line change @@ -230,13 +230,7 @@ internal void ShowWindow()
230
230
}
231
231
}
232
232
233
- internal void BlockUntilClosed ( )
234
- {
235
- if ( _closedEvent != null )
236
- {
237
- _closedEvent . WaitOne ( ) ;
238
- }
239
- }
233
+ internal void BlockUntilClosed ( ) => _closedEvent ? . WaitOne ( ) ;
240
234
241
235
/// <summary>
242
236
/// Implements IDisposable logic.
Original file line number Diff line number Diff line change @@ -224,10 +224,7 @@ private void ProcessMarkdownInfo(MarkdownInfo markdownInfo)
224
224
/// </summary>
225
225
protected override void EndProcessing ( )
226
226
{
227
- if ( _powerShell != null )
228
- {
229
- _powerShell . Dispose ( ) ;
230
- }
227
+ _powerShell ? . Dispose ( ) ;
231
228
}
232
229
}
233
230
}
Original file line number Diff line number Diff line change @@ -91,10 +91,7 @@ private void Sleep(int milliSecondsToSleep)
91
91
}
92
92
}
93
93
94
- if ( _waitHandle != null )
95
- {
96
- _waitHandle . WaitOne ( milliSecondsToSleep , true ) ;
97
- }
94
+ _waitHandle ? . WaitOne ( milliSecondsToSleep , true ) ;
98
95
}
99
96
100
97
/// <summary>
@@ -150,10 +147,7 @@ protected override void StopProcessing()
150
147
lock ( _syncObject )
151
148
{
152
149
_stopping = true ;
153
- if ( _waitHandle != null )
154
- {
155
- _waitHandle . Set ( ) ;
156
- }
150
+ _waitHandle ? . Set ( ) ;
157
151
}
158
152
}
159
153
Original file line number Diff line number Diff line change @@ -1160,10 +1160,7 @@ protected override void ProcessRecord()
1160
1160
indicesToRemove . Sort ( ) ;
1161
1161
for ( int i = indicesToRemove . Count - 1 ; i >= 0 ; i -- )
1162
1162
{
1163
- if ( Context . InitialSessionState != null )
1164
- {
1165
- Context . InitialSessionState . Types . RemoveItem ( indicesToRemove [ i ] ) ;
1166
- }
1163
+ Context . InitialSessionState ? . Types . RemoveItem ( indicesToRemove [ i ] ) ;
1167
1164
}
1168
1165
1169
1166
try
Original file line number Diff line number Diff line change @@ -1578,10 +1578,7 @@ protected override void ProcessRecord()
1578
1578
}
1579
1579
finally
1580
1580
{
1581
- if ( reader != null )
1582
- {
1583
- reader . Dispose ( ) ;
1584
- }
1581
+ reader ? . Dispose ( ) ;
1585
1582
}
1586
1583
1587
1584
if ( ! string . IsNullOrEmpty ( detailMsg ) )
@@ -1657,13 +1654,7 @@ protected override void ProcessRecord()
1657
1654
/// <summary>
1658
1655
/// Implementing ^C, after start the BeginGetResponse.
1659
1656
/// </summary>
1660
- protected override void StopProcessing ( )
1661
- {
1662
- if ( _cancelToken != null )
1663
- {
1664
- _cancelToken . Cancel ( ) ;
1665
- }
1666
- }
1657
+ protected override void StopProcessing ( ) => _cancelToken ? . Cancel ( ) ;
1667
1658
1668
1659
#endregion Overrides
1669
1660
Original file line number Diff line number Diff line change @@ -453,8 +453,7 @@ protected override void ProcessRecord()
453
453
{
454
454
CreateMemoryStream ( ) ;
455
455
456
- if ( _serializer != null )
457
- _serializer . SerializeAsStream ( InputObject ) ;
456
+ _serializer ? . SerializeAsStream ( InputObject ) ;
458
457
459
458
if ( _serializer != null )
460
459
{
@@ -472,8 +471,7 @@ protected override void ProcessRecord()
472
471
}
473
472
else
474
473
{
475
- if ( _serializer != null )
476
- _serializer . Serialize ( InputObject ) ;
474
+ _serializer ? . Serialize ( InputObject ) ;
477
475
}
478
476
}
479
477
@@ -801,13 +799,7 @@ internal void Import()
801
799
}
802
800
}
803
801
804
- internal void Stop ( )
805
- {
806
- if ( _deserializer != null )
807
- {
808
- _deserializer . Stop ( ) ;
809
- }
810
- }
802
+ internal void Stop ( ) => _deserializer ? . Stop ( ) ;
811
803
}
812
804
813
805
#region Select-Xml
You can’t perform that action at this time.
0 commit comments