diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-08 13:17:05 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-08 13:17:05 -0500 |
| commit | 1ead63b0d1a532cf828a4ed7c5310eef9c255740 (patch) | |
| tree | b272e8e09b9e2cb78eb8c641238c3d75bbb08da0 /MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs | |
| parent | 83042f0d1310a0b6ecf0882b6c8027eca9e24c77 (diff) | |
add column sorting to reports
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs b/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs new file mode 100644 index 000000000..5bcd080d7 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/PlayersComparer.cs @@ -0,0 +1,46 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class PlayersComparer : IBaseItemComparer + { + /// <summary> + /// Compares the specified x. + /// </summary> + /// <param name="x">The x.</param> + /// <param name="y">The y.</param> + /// <returns>System.Int32.</returns> + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + /// <summary> + /// Gets the value. + /// </summary> + /// <param name="x">The x.</param> + /// <returns>System.String.</returns> + private int GetValue(BaseItem x) + { + var game = x as Game; + + if (game != null) + { + return game.PlayersSupported ?? 0; + } + + return 0; + } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public string Name + { + get { return ItemSortBy.Players; } + } + } +} |
