Files
jellyfin-jellyfin-1/MediaBrowser.Controller/Dto/DtoOptions.cs

70 lines
1.9 KiB
C#
Raw Normal View History

2014-11-30 14:01:33 -05:00
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
2014-12-27 00:08:39 -05:00
using System;
2014-11-30 14:01:33 -05:00
using System.Collections.Generic;
2014-12-27 00:08:39 -05:00
using System.Linq;
2014-11-30 14:01:33 -05:00
2015-01-03 14:38:22 -05:00
namespace MediaBrowser.Controller.Dto
2014-11-30 14:01:33 -05:00
{
public class DtoOptions
{
2014-12-27 00:08:39 -05:00
private static readonly List<ItemFields> DefaultExcludedFields = new List<ItemFields>
{
2017-06-23 12:04:45 -04:00
ItemFields.SeasonUserData,
ItemFields.RefreshState
2014-12-27 00:08:39 -05:00
};
2017-08-19 15:43:35 -04:00
public ItemFields[] Fields { get; set; }
public ImageType[] ImageTypes { get; set; }
2014-11-30 14:01:33 -05:00
public int ImageTypeLimit { get; set; }
public bool EnableImages { get; set; }
2016-03-22 02:49:36 -04:00
public bool AddProgramRecordingInfo { get; set; }
2015-01-24 14:03:55 -05:00
public string DeviceId { get; set; }
2016-08-17 15:28:43 -04:00
public bool EnableUserData { get; set; }
public bool AddCurrentProgram { get; set; }
2014-11-30 14:01:33 -05:00
public DtoOptions()
2017-05-21 03:25:49 -04:00
: this(true)
{
}
2017-08-19 15:43:35 -04:00
private static readonly ImageType[] AllImageTypes = Enum.GetNames(typeof(ImageType))
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
.ToArray();
private static readonly ItemFields[] AllItemFields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.Except(DefaultExcludedFields)
.ToArray();
2017-05-21 03:25:49 -04:00
public DtoOptions(bool allFields)
2014-11-30 14:01:33 -05:00
{
ImageTypeLimit = int.MaxValue;
EnableImages = true;
2016-08-17 15:28:43 -04:00
EnableUserData = true;
AddCurrentProgram = true;
2014-12-27 00:08:39 -05:00
2017-05-21 03:25:49 -04:00
if (allFields)
{
2017-08-19 15:43:35 -04:00
Fields = AllItemFields;
2017-05-21 03:25:49 -04:00
}
else
{
2017-08-19 15:43:35 -04:00
Fields = new ItemFields[] { };
2017-05-21 03:25:49 -04:00
}
2014-12-27 00:08:39 -05:00
2017-08-19 15:43:35 -04:00
ImageTypes = AllImageTypes;
2014-11-30 14:01:33 -05:00
}
public int GetImageLimit(ImageType type)
{
if (EnableImages && ImageTypes.Contains(type))
{
return ImageTypeLimit;
}
return 0;
}
}
}