Use Null-Propagation Operator

This commit is contained in:
teinarss
2020-08-16 11:38:14 +02:00
committed by Paul Chote
parent 8d27d22100
commit 9c4fd0e3d3
113 changed files with 219 additions and 464 deletions

View File

@@ -174,23 +174,21 @@ namespace OpenRA.Network
foreach (var p in packets)
{
packetFn(p.FromClient, p.Data);
if (Recorder != null)
Recorder.Receive(p.FromClient, p.Data);
Recorder?.Receive(p.FromClient, p.Data);
}
}
public void StartRecording(Func<string> chooseFilename)
{
// If we have a previous recording then save/dispose it and start a new one.
if (Recorder != null)
Recorder.Dispose();
Recorder?.Dispose();
Recorder = new ReplayRecorder(chooseFilename);
}
protected virtual void Dispose(bool disposing)
{
if (disposing && Recorder != null)
Recorder.Dispose();
if (disposing)
Recorder?.Dispose();
}
public void Dispose()
@@ -372,8 +370,7 @@ namespace OpenRA.Network
// Closing the stream will cause any reads on the receiving thread to throw.
// This will mark the connection as no longer connected and the thread will terminate cleanly.
if (tcp != null)
tcp.Close();
tcp?.Close();
base.Dispose(disposing);
}