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

@@ -326,17 +326,13 @@ namespace OpenRA.Platforms.Default
public void StopSound(ISound sound)
{
if (sound == null)
return;
((OpenAlSound)sound).Stop();
((OpenAlSound)sound)?.Stop();
}
public void StopAllSounds()
{
foreach (var slot in sourcePool.Values)
if (slot.Sound != null)
slot.Sound.Stop();
slot.Sound?.Stop();
}
public void SetListenerPosition(WPos position)

View File

@@ -415,8 +415,7 @@ namespace OpenRA.Platforms.Default
disposed = true;
if (context != null)
context.Dispose();
context?.Dispose();
if (Window != IntPtr.Zero)
SDL.SDL_DestroyWindow(Window);

View File

@@ -260,8 +260,7 @@ namespace OpenRA.Platforms.Default
var localResult = result;
result = null;
if (localEdi != null)
localEdi.Throw();
localEdi?.Throw();
return localResult;
}
}
@@ -278,8 +277,7 @@ namespace OpenRA.Platforms.Default
void QueueMessage(Message message)
{
var exception = messageException;
if (exception != null)
exception.Throw();
exception?.Throw();
lock (messages)
{