Files
wjones af1152b001 Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
2026-02-20 16:26:53 -05:00

47 lines
1.5 KiB
C#

// <copyright file="AlbumArtistComparer.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Emby.Server.Implementations.Sorting
{
using System;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
/// <summary>
/// Allows comparing artists of albums. Only the first artist of each album is considered.
/// </summary>
public class AlbumArtistComparer : IBaseItemComparer
{
/// <summary>
/// Gets the item type this comparer compares.
/// </summary>
public ItemSortBy Type => ItemSortBy.AlbumArtist;
/// <summary>
/// Compares the specified arguments on their primary artist.
/// </summary>
/// <param name="x">First item to compare.</param>
/// <param name="y">Second item to compare.</param>
/// <returns>Zero if equal, else negative or positive number to indicate order.</returns>
public int Compare(BaseItem? x, BaseItem? y)
{
return string.Compare(GetFirstAlbumArtist(x), GetFirstAlbumArtist(y), StringComparison.OrdinalIgnoreCase);
}
private static string? GetFirstAlbumArtist(BaseItem? x)
{
if (x is IHasAlbumArtist audio
&& audio.AlbumArtists.Count != 0)
{
return audio.AlbumArtists[0];
}
return null;
}
}
}