From 9e0c1340fc3ad4b41e3c349b98ea71b708ade95a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 2 Feb 2014 08:36:31 -0500 Subject: convert games to new providers --- .../Configuration/MetadataOptions.cs | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 MediaBrowser.Model/Configuration/MetadataOptions.cs (limited to 'MediaBrowser.Model/Configuration/MetadataOptions.cs') diff --git a/MediaBrowser.Model/Configuration/MetadataOptions.cs b/MediaBrowser.Model/Configuration/MetadataOptions.cs new file mode 100644 index 000000000..f914a2d21 --- /dev/null +++ b/MediaBrowser.Model/Configuration/MetadataOptions.cs @@ -0,0 +1,89 @@ +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace MediaBrowser.Model.Configuration +{ + /// + /// Class MetadataOptions. + /// + public class MetadataOptions + { + public string ItemType { get; set; } + + public ImageOption[] ImageOptions { get; set; } + + public string[] DisabledMetadataSavers { get; set; } + + public MetadataOptions() + : this(3, 1280) + { + } + + public MetadataOptions(int backdropLimit, int minBackdropWidth) + { + var imageOptions = new List + { + new ImageOption + { + Limit = backdropLimit, + MinWidth = minBackdropWidth, + Type = ImageType.Backdrop + } + }; + + ImageOptions = imageOptions.ToArray(); + DisabledMetadataSavers = new string[] { }; + } + + public int GetLimit(ImageType type) + { + var option = ImageOptions.FirstOrDefault(i => i.Type == type); + + return option == null ? 1 : option.Limit; + } + + public int GetMinWidth(ImageType type) + { + var option = ImageOptions.FirstOrDefault(i => i.Type == type); + + return option == null ? 0 : option.MinWidth; + } + + public bool IsEnabled(ImageType type) + { + return GetLimit(type) > 0; + } + + public bool IsMetadataSaverEnabled(string name) + { + return !DisabledMetadataSavers.Contains(name, StringComparer.OrdinalIgnoreCase); + } + } + + public class ImageOption + { + /// + /// Gets or sets the type. + /// + /// The type. + public ImageType Type { get; set; } + /// + /// Gets or sets the limit. + /// + /// The limit. + public int Limit { get; set; } + + /// + /// Gets or sets the minimum width. + /// + /// The minimum width. + public int MinWidth { get; set; } + + public ImageOption() + { + Limit = 1; + } + } +} -- cgit v1.2.3