using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Sorting
{
    public class GameSystemComparer : IBaseItemComparer
    {
        /// 
        /// Compares the specified x.
        /// 
        /// The x.
        /// The y.
        /// System.Int32.
        public int Compare(BaseItem x, BaseItem y)
        {
            return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
        }
        /// 
        /// Gets the value.
        /// 
        /// The x.
        /// System.String.
        private static string GetValue(BaseItem x)
        {
            var game = x as Game;
            if (game != null)
            {
                return game.GameSystem;
            }
            var system = x as GameSystem;
            if (system != null)
            {
                return system.GameSystemName;
            }
            return string.Empty;
        }
        /// 
        /// Gets the name.
        /// 
        /// The name.
        public string Name => ItemSortBy.GameSystem;
    }
}