Use null propagation

pull/10366/head
Stepan Goremykin 8 months ago
parent 212976277d
commit fdef9356b9

@ -927,14 +927,11 @@ namespace Emby.Dlna.PlayTo
var resElement = container.Element(UPnpNamespaces.Res); var resElement = container.Element(UPnpNamespaces.Res);
if (resElement is not null) var info = resElement?.Attribute(UPnpNamespaces.ProtocolInfo);
{
var info = resElement.Attribute(UPnpNamespaces.ProtocolInfo);
if (info is not null && !string.IsNullOrWhiteSpace(info.Value)) if (info is not null && !string.IsNullOrWhiteSpace(info.Value))
{ {
return info.Value.Split(':'); return info.Value.Split(':');
}
} }
return new string[4]; return new string[4];

@ -3540,10 +3540,7 @@ namespace Emby.Server.Implementations.Data
.Append(paramName) .Append(paramName)
.Append("))) OR "); .Append("))) OR ");
if (statement is not null) statement?.TryBind(paramName, query.PersonIds[i]);
{
statement.TryBind(paramName, query.PersonIds[i]);
}
} }
clauseBuilder.Length -= Or.Length; clauseBuilder.Length -= Or.Length;

@ -95,10 +95,7 @@ namespace MediaBrowser.Controller.Entities
} }
var p = destProps.Find(x => x.Name == sourceProp.Name); var p = destProps.Find(x => x.Name == sourceProp.Name);
if (p is not null) p?.SetValue(dest, v);
{
p.SetValue(dest, v);
}
} }
} }

@ -33,10 +33,7 @@ namespace Rssdp.Infrastructure
} }
finally finally
{ {
if (retVal != null) retVal?.Dispose();
{
retVal.Dispose();
}
} }
} }

@ -33,10 +33,7 @@ namespace Rssdp.Infrastructure
} }
catch catch
{ {
if (retVal != null) retVal?.Dispose();
{
retVal.Dispose();
}
throw; throw;
} }

@ -512,22 +512,16 @@ namespace Rssdp.Infrastructure
} }
var handlers = this.RequestReceived; var handlers = this.RequestReceived;
if (handlers is not null) handlers?.Invoke(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnlocalIPAddress));
{
handlers(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnlocalIPAddress));
}
} }
private void OnResponseReceived(HttpResponseMessage data, IPEndPoint endPoint, IPAddress localIPAddress) private void OnResponseReceived(HttpResponseMessage data, IPEndPoint endPoint, IPAddress localIPAddress)
{ {
var handlers = this.ResponseReceived; var handlers = this.ResponseReceived;
if (handlers is not null) handlers?.Invoke(this, new ResponseReceivedEventArgs(data, endPoint)
{ {
handlers(this, new ResponseReceivedEventArgs(data, endPoint) LocalIPAddress = localIPAddress
{ });
LocalIPAddress = localIPAddress
});
}
} }
} }
} }

@ -337,10 +337,7 @@ namespace Rssdp
protected virtual void OnDeviceAdded(SsdpEmbeddedDevice device) protected virtual void OnDeviceAdded(SsdpEmbeddedDevice device)
{ {
var handlers = this.DeviceAdded; var handlers = this.DeviceAdded;
if (handlers != null) handlers?.Invoke(this, new DeviceEventArgs(device));
{
handlers(this, new DeviceEventArgs(device));
}
} }
/// <summary> /// <summary>
@ -352,10 +349,7 @@ namespace Rssdp
protected virtual void OnDeviceRemoved(SsdpEmbeddedDevice device) protected virtual void OnDeviceRemoved(SsdpEmbeddedDevice device)
{ {
var handlers = this.DeviceRemoved; var handlers = this.DeviceRemoved;
if (handlers != null) handlers?.Invoke(this, new DeviceEventArgs(device));
{
handlers(this, new DeviceEventArgs(device));
}
} }
} }
} }

@ -227,13 +227,10 @@ namespace Rssdp.Infrastructure
} }
var handlers = this.DeviceAvailable; var handlers = this.DeviceAvailable;
if (handlers is not null) handlers?.Invoke(this, new DeviceAvailableEventArgs(device, isNewDevice)
{ {
handlers(this, new DeviceAvailableEventArgs(device, isNewDevice) RemoteIPAddress = IPAddress
{ });
RemoteIPAddress = IPAddress
});
}
} }
/// <summary> /// <summary>
@ -250,10 +247,7 @@ namespace Rssdp.Infrastructure
} }
var handlers = this.DeviceUnavailable; var handlers = this.DeviceUnavailable;
if (handlers is not null) handlers?.Invoke(this, new DeviceUnavailableEventArgs(device, expired));
{
handlers(this, new DeviceUnavailableEventArgs(device, expired));
}
} }
/// <summary> /// <summary>

@ -527,10 +527,7 @@ namespace Rssdp.Infrastructure
{ {
var timer = _RebroadcastAliveNotificationsTimer; var timer = _RebroadcastAliveNotificationsTimer;
_RebroadcastAliveNotificationsTimer = null; _RebroadcastAliveNotificationsTimer = null;
if (timer is not null) timer?.Dispose();
{
timer.Dispose();
}
} }
private TimeSpan GetMinimumNonZeroCacheLifetime() private TimeSpan GetMinimumNonZeroCacheLifetime()
@ -564,10 +561,7 @@ namespace Rssdp.Infrastructure
private void WriteTrace(string text) private void WriteTrace(string text)
{ {
if (LogFunction is not null) LogFunction?.Invoke(text);
{
LogFunction(text);
}
// System.Diagnostics.Debug.WriteLine(text, "SSDP Publisher"); // System.Diagnostics.Debug.WriteLine(text, "SSDP Publisher");
} }

Loading…
Cancel
Save