diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-15 00:01:58 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-15 00:01:58 -0500 |
| commit | 7d4f33f0e0eac3cd5d3829c01df47ad88675607a (patch) | |
| tree | 54707d4d1b1abc7ff3e4ff774c61c0ea340ee1e8 /MediaBrowser.Server.Implementations/Sorting | |
| parent | 5898627254b60138b2aed6ef8cff9d002b310a14 (diff) | |
add new fields from omdb
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sorting')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs new file mode 100644 index 000000000..bfd162661 --- /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 + { + /// <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)); + } + + private float GetValue(BaseItem x) + { + var hasMetascore = x as IHasMetascore; + + if (hasMetascore != null) + { + return hasMetascore.Metascore ?? 0; + } + + return 0; + } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public string Name + { + get { return ItemSortBy.Metascore; } + } + } +} |
