From 7d4f33f0e0eac3cd5d3829c01df47ad88675607a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 15 Jan 2014 00:01:58 -0500 Subject: add new fields from omdb --- .../Sorting/MetascoreComparer.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting') diff --git a/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs new file mode 100644 index 0000000000..bfd1626615 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs @@ -0,0 +1,41 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class MetascoreComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + private float GetValue(BaseItem x) + { + var hasMetascore = x as IHasMetascore; + + if (hasMetascore != null) + { + return hasMetascore.Metascore ?? 0; + } + + return 0; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.Metascore; } + } + } +} -- cgit v1.2.3