mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-02-23 13:02:26 +00:00
Optimize Guid comparisons
* Use Guid.Equals(Guid) instead of the == override * Ban the usage of Guid.Equals(Object) to prevent accidental boxing * Compare to default(Guid) instead of Guid.Empty
This commit is contained in:
@@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
/// <inheritdoc />
|
||||
public QueryResult<Channel> GetChannelsInternal(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(Guid.Empty)
|
||||
var user = query.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
/// <inheritdoc />
|
||||
public QueryResult<BaseItemDto> GetChannels(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(Guid.Empty)
|
||||
var user = query.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
@@ -474,7 +474,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
item.ChannelId = id;
|
||||
|
||||
if (item.ParentId != parentFolderId)
|
||||
if (!item.ParentId.Equals(parentFolderId))
|
||||
{
|
||||
forceUpdate = true;
|
||||
}
|
||||
@@ -715,7 +715,9 @@ namespace Emby.Server.Implementations.Channels
|
||||
// Find the corresponding channel provider plugin
|
||||
var channelProvider = GetChannelProvider(channel);
|
||||
|
||||
var parentItem = query.ParentId == Guid.Empty ? channel : _libraryManager.GetItemById(query.ParentId);
|
||||
var parentItem = query.ParentId.Equals(default)
|
||||
? channel
|
||||
: _libraryManager.GetItemById(query.ParentId);
|
||||
|
||||
var itemsResult = await GetChannelItems(
|
||||
channelProvider,
|
||||
@@ -726,7 +728,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (query.ParentId == Guid.Empty)
|
||||
if (query.ParentId.Equals(default))
|
||||
{
|
||||
query.Parent = channel;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
{
|
||||
var childItem = _libraryManager.GetItemById(guidId);
|
||||
|
||||
var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == guidId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
|
||||
var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
|
||||
|
||||
if (child == null)
|
||||
{
|
||||
|
||||
@@ -1308,7 +1308,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
|
||||
var allImages = parent.ImageInfos;
|
||||
|
||||
if (logoLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId == null)
|
||||
if (logoLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId is null)
|
||||
{
|
||||
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Logo);
|
||||
|
||||
@@ -1319,7 +1319,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId == null)
|
||||
if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId is null)
|
||||
{
|
||||
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Art);
|
||||
|
||||
@@ -1330,7 +1330,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId == null || parent is Series) && parent is not ICollectionFolder && parent is not UserView)
|
||||
if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId is null || parent is Series) && parent is not ICollectionFolder && parent is not UserView)
|
||||
{
|
||||
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb);
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
var userIds = _sessionManager.Sessions
|
||||
.Select(i => i.UserId)
|
||||
.Where(i => !i.Equals(Guid.Empty))
|
||||
.Where(i => !i.Equals(default))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
var session = await GetSession(requestContext).ConfigureAwait(false);
|
||||
|
||||
return session.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(session.UserId);
|
||||
return session.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(session.UserId);
|
||||
}
|
||||
|
||||
public Task<User?> GetUser(object requestContext)
|
||||
|
||||
@@ -755,7 +755,7 @@ namespace Emby.Server.Implementations.Library
|
||||
Path = path
|
||||
};
|
||||
|
||||
if (folder.Id.Equals(Guid.Empty))
|
||||
if (folder.Id.Equals(default))
|
||||
{
|
||||
if (string.IsNullOrEmpty(folder.Path))
|
||||
{
|
||||
@@ -774,7 +774,7 @@ namespace Emby.Server.Implementations.Library
|
||||
folder = dbItem;
|
||||
}
|
||||
|
||||
if (folder.ParentId != rootFolder.Id)
|
||||
if (!folder.ParentId.Equals(rootFolder.Id))
|
||||
{
|
||||
folder.ParentId = rootFolder.Id;
|
||||
folder.UpdateToRepositoryAsync(ItemUpdateType.MetadataImport, CancellationToken.None).GetAwaiter().GetResult();
|
||||
@@ -1252,7 +1252,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <c>null</c>.</exception>
|
||||
public BaseItem GetItemById(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
if (id.Equals(default))
|
||||
{
|
||||
throw new ArgumentException("Guid can't be empty", nameof(id));
|
||||
}
|
||||
@@ -1274,7 +1274,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public List<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent)
|
||||
{
|
||||
if (query.Recursive && query.ParentId != Guid.Empty)
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent != null)
|
||||
@@ -1298,7 +1298,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public int GetCount(InternalItemsQuery query)
|
||||
{
|
||||
if (query.Recursive && !query.ParentId.Equals(Guid.Empty))
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent != null)
|
||||
@@ -1456,7 +1456,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
|
||||
{
|
||||
if (query.Recursive && !query.ParentId.Equals(Guid.Empty))
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent != null)
|
||||
@@ -1512,7 +1512,7 @@ namespace Emby.Server.Implementations.Library
|
||||
private void AddUserToQuery(InternalItemsQuery query, User user, bool allowExternalContent = true)
|
||||
{
|
||||
if (query.AncestorIds.Length == 0 &&
|
||||
query.ParentId.Equals(Guid.Empty) &&
|
||||
query.ParentId.Equals(default) &&
|
||||
query.ChannelIds.Count == 0 &&
|
||||
query.TopParentIds.Length == 0 &&
|
||||
string.IsNullOrEmpty(query.AncestorWithPresentationUniqueKey) &&
|
||||
@@ -1540,7 +1540,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// Translate view into folders
|
||||
if (!view.DisplayParentId.Equals(Guid.Empty))
|
||||
if (!view.DisplayParentId.Equals(default))
|
||||
{
|
||||
var displayParent = GetItemById(view.DisplayParentId);
|
||||
if (displayParent != null)
|
||||
@@ -1551,7 +1551,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return Array.Empty<Guid>();
|
||||
}
|
||||
|
||||
if (!view.ParentId.Equals(Guid.Empty))
|
||||
if (!view.ParentId.Equals(default))
|
||||
{
|
||||
var displayParent = GetItemById(view.ParentId);
|
||||
if (displayParent != null)
|
||||
@@ -2153,7 +2153,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
while (!item.ParentId.Equals(Guid.Empty))
|
||||
while (!item.ParentId.Equals(default))
|
||||
{
|
||||
var parent = item.GetParent();
|
||||
if (parent == null || parent is AggregateFolder)
|
||||
@@ -2231,7 +2231,9 @@ namespace Emby.Server.Implementations.Library
|
||||
string viewType,
|
||||
string sortName)
|
||||
{
|
||||
var parentIdString = parentId.Equals(Guid.Empty) ? null : parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var parentIdString = parentId.Equals(default)
|
||||
? null
|
||||
: parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var idValues = "38_namedview_" + name + user.Id.ToString("N", CultureInfo.InvariantCulture) + (parentIdString ?? string.Empty) + (viewType ?? string.Empty);
|
||||
|
||||
var id = GetNewItemId(idValues, typeof(UserView));
|
||||
@@ -2265,7 +2267,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(Guid.Empty))
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
@@ -2332,7 +2334,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(Guid.Empty))
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
@@ -2365,7 +2367,9 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var parentIdString = parentId.Equals(Guid.Empty) ? null : parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var parentIdString = parentId.Equals(default)
|
||||
? null
|
||||
: parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var idValues = "37_namedview_" + name + (parentIdString ?? string.Empty) + (viewType ?? string.Empty);
|
||||
if (!string.IsNullOrEmpty(uniqueId))
|
||||
{
|
||||
@@ -2409,7 +2413,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(Guid.Empty))
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
|
||||
@@ -514,10 +514,10 @@ namespace Emby.Server.Implementations.Library
|
||||
_logger.LogInformation("Live stream opened: {@MediaSource}", mediaSource);
|
||||
var clone = JsonSerializer.Deserialize<MediaSourceInfo>(json, _jsonOptions);
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
if (!request.UserId.Equals(default))
|
||||
{
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
var item = request.ItemId.Equals(Guid.Empty)
|
||||
var item = request.ItemId.Equals(default)
|
||||
? null
|
||||
: _libraryManager.GetItemById(request.ItemId);
|
||||
SetDefaultAudioAndSubtitleStreamIndexes(item, clone, user);
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
return Guid.Empty;
|
||||
}
|
||||
}).Where(i => !i.Equals(Guid.Empty)).ToArray();
|
||||
}).Where(i => !i.Equals(default)).ToArray();
|
||||
|
||||
return GetInstantMixFromGenreIds(genreIds, user, dtoOptions);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Library
|
||||
public QueryResult<SearchHintInfo> GetSearchHints(SearchQuery query)
|
||||
{
|
||||
User user = null;
|
||||
if (query.UserId != Guid.Empty)
|
||||
if (!query.UserId.Equals(default))
|
||||
{
|
||||
user = _userManager.GetUserById(query.UserId);
|
||||
}
|
||||
@@ -168,10 +168,10 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
Fields = new ItemFields[]
|
||||
{
|
||||
ItemFields.AirTime,
|
||||
ItemFields.DateCreated,
|
||||
ItemFields.ChannelInfo,
|
||||
ItemFields.ParentId
|
||||
ItemFields.AirTime,
|
||||
ItemFields.DateCreated,
|
||||
ItemFields.ChannelInfo,
|
||||
ItemFields.ParentId
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -180,12 +180,12 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (searchQuery.IncludeItemTypes.Length == 1 && searchQuery.IncludeItemTypes[0] == BaseItemKind.MusicArtist)
|
||||
{
|
||||
if (!searchQuery.ParentId.Equals(Guid.Empty))
|
||||
if (!searchQuery.ParentId.Equals(default))
|
||||
{
|
||||
searchQuery.AncestorIds = new[] { searchQuery.ParentId };
|
||||
searchQuery.ParentId = Guid.Empty;
|
||||
}
|
||||
|
||||
searchQuery.ParentId = Guid.Empty;
|
||||
searchQuery.IncludeItemsByName = true;
|
||||
searchQuery.IncludeItemTypes = Array.Empty<BaseItemKind>();
|
||||
mediaItems = _libraryManager.GetAllArtists(searchQuery).Items.Select(i => i.Item).ToList();
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (index == -1
|
||||
&& i is UserView view
|
||||
&& view.DisplayParentId != Guid.Empty)
|
||||
&& !view.DisplayParentId.Equals(default))
|
||||
{
|
||||
index = Array.IndexOf(orders, view.DisplayParentId);
|
||||
}
|
||||
@@ -214,7 +214,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id == container.Id);
|
||||
var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id.Equals(container.Id));
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
@@ -244,7 +244,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var parents = new List<BaseItem>();
|
||||
|
||||
if (!parentId.Equals(Guid.Empty))
|
||||
if (!parentId.Equals(default))
|
||||
{
|
||||
var parentItem = _libraryManager.GetItemById(parentId);
|
||||
if (parentItem is Channel)
|
||||
|
||||
@@ -2024,7 +2024,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
await writer.WriteElementStringAsync(null, "genre", null, genre).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var people = item.Id.Equals(Guid.Empty) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
|
||||
var people = item.Id.Equals(default) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
|
||||
|
||||
var directors = people
|
||||
.Where(i => IsPersonType(i, PersonType.Director))
|
||||
@@ -2382,7 +2382,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
string channelId = seriesTimer.RecordAnyChannel ? null : seriesTimer.ChannelId;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty))
|
||||
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(default))
|
||||
{
|
||||
if (!tempChannelCache.TryGetValue(parent.ChannelId, out LiveTvChannel channel))
|
||||
{
|
||||
@@ -2441,7 +2441,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
string channelId = null;
|
||||
|
||||
if (!programInfo.ChannelId.Equals(Guid.Empty))
|
||||
if (!programInfo.ChannelId.Equals(default))
|
||||
{
|
||||
if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out LiveTvChannel channel))
|
||||
{
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
info.Id = timer.ExternalId;
|
||||
}
|
||||
|
||||
if (!dto.ChannelId.Equals(Guid.Empty) && string.IsNullOrEmpty(info.ChannelId))
|
||||
if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
|
||||
{
|
||||
var channel = _libraryManager.GetItemById(dto.ChannelId);
|
||||
|
||||
@@ -522,7 +522,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
info.Id = timer.ExternalId;
|
||||
}
|
||||
|
||||
if (!dto.ChannelId.Equals(Guid.Empty) && string.IsNullOrEmpty(info.ChannelId))
|
||||
if (!dto.ChannelId.Equals(default) && string.IsNullOrEmpty(info.ChannelId))
|
||||
{
|
||||
var channel = _libraryManager.GetItemById(dto.ChannelId);
|
||||
|
||||
|
||||
@@ -176,7 +176,9 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
public QueryResult<BaseItem> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = query.UserId == Guid.Empty ? null : _userManager.GetUserById(query.UserId);
|
||||
var user = query.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
var topFolder = GetInternalLiveTvFolder(cancellationToken);
|
||||
|
||||
@@ -1268,7 +1270,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (itemId.Equals(Guid.Empty))
|
||||
if (itemId.Equals(default))
|
||||
{
|
||||
// Somehow some invalid data got into the db. It probably predates the boundary checking
|
||||
continue;
|
||||
@@ -1528,7 +1530,9 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
public QueryResult<BaseItemDto> GetRecordings(RecordingQuery query, DtoOptions options)
|
||||
{
|
||||
var user = query.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(query.UserId);
|
||||
var user = query.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(query.UserId);
|
||||
|
||||
RemoveFields(options);
|
||||
|
||||
@@ -1587,7 +1591,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
if (!string.IsNullOrEmpty(query.ChannelId))
|
||||
{
|
||||
var guid = new Guid(query.ChannelId);
|
||||
timers = timers.Where(i => guid == _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId));
|
||||
timers = timers.Where(i => _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId).Equals(guid));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.SeriesTimerId))
|
||||
@@ -1595,7 +1599,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
var guid = new Guid(query.SeriesTimerId);
|
||||
|
||||
timers = timers
|
||||
.Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId) == guid);
|
||||
.Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId).Equals(guid));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.Id))
|
||||
@@ -1657,7 +1661,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
if (!string.IsNullOrEmpty(query.ChannelId))
|
||||
{
|
||||
var guid = new Guid(query.ChannelId);
|
||||
timers = timers.Where(i => guid == _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId));
|
||||
timers = timers.Where(i => _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId).Equals(guid));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.SeriesTimerId))
|
||||
@@ -1665,7 +1669,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
var guid = new Guid(query.SeriesTimerId);
|
||||
|
||||
timers = timers
|
||||
.Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId) == guid);
|
||||
.Where(i => _tvDtoService.GetInternalSeriesTimerId(i.Item1.SeriesTimerId).Equals(guid));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.Id))
|
||||
|
||||
@@ -139,7 +139,9 @@ namespace Emby.Server.Implementations.Playlists
|
||||
{
|
||||
new Share
|
||||
{
|
||||
UserId = options.UserId.Equals(Guid.Empty) ? null : options.UserId.ToString("N", CultureInfo.InvariantCulture),
|
||||
UserId = options.UserId.Equals(default)
|
||||
? null
|
||||
: options.UserId.ToString("N", CultureInfo.InvariantCulture),
|
||||
CanEdit = true
|
||||
}
|
||||
}
|
||||
@@ -188,7 +190,7 @@ namespace Emby.Server.Implementations.Playlists
|
||||
|
||||
public Task AddToPlaylistAsync(Guid playlistId, IReadOnlyCollection<Guid> itemIds, Guid userId)
|
||||
{
|
||||
var user = userId.Equals(Guid.Empty) ? null : _userManager.GetUserById(userId);
|
||||
var user = userId.Equals(default) ? null : _userManager.GetUserById(userId);
|
||||
|
||||
return AddToPlaylistInternal(playlistId, itemIds, user, new DtoOptions(false)
|
||||
{
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace Emby.Server.Implementations.Plugins
|
||||
var pluginStr = instance.Version.ToString();
|
||||
bool changed = false;
|
||||
if (string.Equals(manifest.Version, pluginStr, StringComparison.Ordinal)
|
||||
|| manifest.Id != instance.Id)
|
||||
|| !manifest.Id.Equals(instance.Id))
|
||||
{
|
||||
// If a plugin without a manifest failed to load due to an external issue (eg config),
|
||||
// this updates the manifest to the actual plugin values.
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace Emby.Server.Implementations.Session
|
||||
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (!info.ItemId.Equals(Guid.Empty) && info.Item == null && libraryItem != null)
|
||||
if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null)
|
||||
{
|
||||
var current = session.NowPlayingItem;
|
||||
|
||||
@@ -553,22 +553,24 @@ namespace Emby.Server.Implementations.Session
|
||||
{
|
||||
var users = new List<User>();
|
||||
|
||||
if (session.UserId != Guid.Empty)
|
||||
if (session.UserId.Equals(default))
|
||||
{
|
||||
var user = _userManager.GetUserById(session.UserId);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
throw new InvalidOperationException("User not found");
|
||||
}
|
||||
|
||||
users.Add(user);
|
||||
|
||||
users.AddRange(session.AdditionalUsers
|
||||
.Select(i => _userManager.GetUserById(i.UserId))
|
||||
.Where(i => i != null));
|
||||
return users;
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserById(session.UserId);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
throw new InvalidOperationException("User not found");
|
||||
}
|
||||
|
||||
users.Add(user);
|
||||
|
||||
users.AddRange(session.AdditionalUsers
|
||||
.Select(i => _userManager.GetUserById(i.UserId))
|
||||
.Where(i => i != null));
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
@@ -660,7 +662,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
var session = GetSession(info.SessionId);
|
||||
|
||||
var libraryItem = info.ItemId == Guid.Empty
|
||||
var libraryItem = info.ItemId.Equals(default)
|
||||
? null
|
||||
: GetNowPlayingItem(session, info.ItemId);
|
||||
|
||||
@@ -755,7 +757,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
var session = GetSession(info.SessionId);
|
||||
|
||||
var libraryItem = info.ItemId.Equals(Guid.Empty)
|
||||
var libraryItem = info.ItemId.Equals(default)
|
||||
? null
|
||||
: GetNowPlayingItem(session, info.ItemId);
|
||||
|
||||
@@ -892,7 +894,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
session.StopAutomaticProgress();
|
||||
|
||||
var libraryItem = info.ItemId.Equals(Guid.Empty)
|
||||
var libraryItem = info.ItemId.Equals(default)
|
||||
? null
|
||||
: GetNowPlayingItem(session, info.ItemId);
|
||||
|
||||
@@ -902,7 +904,7 @@ namespace Emby.Server.Implementations.Session
|
||||
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (!info.ItemId.Equals(Guid.Empty) && info.Item == null && libraryItem != null)
|
||||
if (!info.ItemId.Equals(default) && info.Item == null && libraryItem != null)
|
||||
{
|
||||
var current = session.NowPlayingItem;
|
||||
|
||||
@@ -1122,7 +1124,7 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
var session = GetSessionToRemoteControl(sessionId);
|
||||
|
||||
var user = session.UserId == Guid.Empty ? null : _userManager.GetUserById(session.UserId);
|
||||
var user = session.UserId.Equals(default) ? null : _userManager.GetUserById(session.UserId);
|
||||
|
||||
List<BaseItem> items;
|
||||
|
||||
@@ -1177,7 +1179,7 @@ namespace Emby.Server.Implementations.Session
|
||||
EnableImages = false
|
||||
})
|
||||
.Where(i => !i.IsVirtualItem)
|
||||
.SkipWhile(i => i.Id != episode.Id)
|
||||
.SkipWhile(i => !i.Id.Equals(episode.Id))
|
||||
.ToList();
|
||||
|
||||
if (episodes.Count > 0)
|
||||
@@ -1191,7 +1193,7 @@ namespace Emby.Server.Implementations.Session
|
||||
{
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
if (!controllingSession.UserId.Equals(Guid.Empty))
|
||||
if (!controllingSession.UserId.Equals(default))
|
||||
{
|
||||
command.ControllingUserId = controllingSession.UserId;
|
||||
}
|
||||
@@ -1310,7 +1312,7 @@ namespace Emby.Server.Implementations.Session
|
||||
{
|
||||
var controllingSession = GetSession(controllingSessionId);
|
||||
AssertCanControl(session, controllingSession);
|
||||
if (!controllingSession.UserId.Equals(Guid.Empty))
|
||||
if (!controllingSession.UserId.Equals(default))
|
||||
{
|
||||
command.ControllingUserId = controllingSession.UserId.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
@@ -1383,12 +1385,12 @@ namespace Emby.Server.Implementations.Session
|
||||
|
||||
var session = GetSession(sessionId);
|
||||
|
||||
if (session.UserId == userId)
|
||||
if (session.UserId.Equals(userId))
|
||||
{
|
||||
throw new ArgumentException("The requested user is already the primary user of the session.");
|
||||
}
|
||||
|
||||
if (session.AdditionalUsers.All(i => i.UserId != userId))
|
||||
if (session.AdditionalUsers.All(i => !i.UserId.Equals(userId)))
|
||||
{
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
@@ -1458,7 +1460,7 @@ namespace Emby.Server.Implementations.Session
|
||||
CheckDisposed();
|
||||
|
||||
User user = null;
|
||||
if (request.UserId != Guid.Empty)
|
||||
if (!request.UserId.Equals(default))
|
||||
{
|
||||
user = _userManager.GetUserById(request.UserId);
|
||||
}
|
||||
@@ -1787,7 +1789,7 @@ namespace Emby.Server.Implementations.Session
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
|
||||
var user = info.UserId == Guid.Empty
|
||||
var user = info.UserId.Equals(default)
|
||||
? null
|
||||
: _userManager.GetUserById(info.UserId);
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ namespace Emby.Server.Implementations.SyncPlay
|
||||
if (playingItemRemoved)
|
||||
{
|
||||
var itemId = PlayQueue.GetPlayingItemId();
|
||||
if (!itemId.Equals(Guid.Empty))
|
||||
if (!itemId.Equals(default))
|
||||
{
|
||||
var item = _libraryManager.GetItemById(itemId);
|
||||
RunTimeTicks = item.RunTimeTicks ?? 0;
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.TV
|
||||
.Cast<Episode>();
|
||||
if (lastWatchedEpisode != null)
|
||||
{
|
||||
sortedConsideredEpisodes = sortedConsideredEpisodes.SkipWhile(episode => episode.Id != lastWatchedEpisode.Id).Skip(1);
|
||||
sortedConsideredEpisodes = sortedConsideredEpisodes.SkipWhile(episode => !episode.Id.Equals(lastWatchedEpisode.Id)).Skip(1);
|
||||
}
|
||||
|
||||
nextEpisode = sortedConsideredEpisodes.FirstOrDefault();
|
||||
|
||||
@@ -227,9 +227,9 @@ namespace Emby.Server.Implementations.Updates
|
||||
availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (id != default)
|
||||
if (!id.Equals(default))
|
||||
{
|
||||
availablePackages = availablePackages.Where(x => x.Id == id);
|
||||
availablePackages = availablePackages.Where(x => x.Id.Equals(id));
|
||||
}
|
||||
|
||||
if (specificVersion != null)
|
||||
@@ -399,7 +399,7 @@ namespace Emby.Server.Implementations.Updates
|
||||
{
|
||||
lock (_currentInstallationsLock)
|
||||
{
|
||||
var install = _currentInstallations.Find(x => x.Info.Id == id);
|
||||
var install = _currentInstallations.Find(x => x.Info.Id.Equals(id));
|
||||
if (install == default((InstallationInfo, CancellationTokenSource)))
|
||||
{
|
||||
return false;
|
||||
@@ -498,7 +498,7 @@ namespace Emby.Server.Implementations.Updates
|
||||
var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
|
||||
var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
|
||||
|
||||
if (version != null && CompletedInstallations.All(x => x.Id != version.Id))
|
||||
if (version != null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
|
||||
{
|
||||
yield return version;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user