Use MinBy and MaxBy

This commit is contained in:
Stepan Goremykin
2023-04-01 23:00:51 +02:00
parent eb59456e78
commit e74630a613
5 changed files with 5 additions and 10 deletions

View File

@@ -304,7 +304,7 @@ namespace Emby.Server.Implementations.Plugins
// If no version is given, return the current instance.
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.MaxBy(p => p.Version);
}
else
{

View File

@@ -69,9 +69,7 @@ namespace Emby.Server.Implementations.Session
T data,
CancellationToken cancellationToken)
{
var socket = GetActiveSockets()
.OrderByDescending(i => i.LastActivityDate)
.FirstOrDefault();
var socket = GetActiveSockets().MaxBy(i => i.LastActivityDate);
if (socket is null)
{