< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Dto.DtoOptions
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Dto/DtoOptions.cs
Line coverage
95%
Covered lines: 21
Uncovered lines: 1
Coverable lines: 22
Total lines: 68
Line coverage: 95.4%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
.ctor(...)100%22100%
ContainsField(...)100%11100%
GetImageLimit(...)50%4.59466.66%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Dto/DtoOptions.cs

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Linq;
 6using MediaBrowser.Model.Entities;
 7using MediaBrowser.Model.Querying;
 8
 9namespace MediaBrowser.Controller.Dto
 10{
 11    public class DtoOptions
 12    {
 113        private static readonly ItemFields[] DefaultExcludedFields = new[]
 114        {
 115            ItemFields.SeasonUserData,
 116            ItemFields.RefreshState
 117        };
 18
 119        private static readonly ImageType[] AllImageTypes = Enum.GetValues<ImageType>();
 20
 121        private static readonly ItemFields[] AllItemFields = Enum.GetValues<ItemFields>()
 122            .Except(DefaultExcludedFields)
 123            .ToArray();
 24
 25        public DtoOptions()
 37126            : this(true)
 27        {
 37128        }
 29
 30        public DtoOptions(bool allFields)
 31        {
 64532            ImageTypeLimit = int.MaxValue;
 64533            EnableImages = true;
 64534            EnableUserData = true;
 64535            AddCurrentProgram = true;
 36
 64537            Fields = allFields ? AllItemFields : Array.Empty<ItemFields>();
 64538            ImageTypes = AllImageTypes;
 64539        }
 40
 41        public IReadOnlyList<ItemFields> Fields { get; set; }
 42
 43        public IReadOnlyList<ImageType> ImageTypes { get; set; }
 44
 45        public int ImageTypeLimit { get; set; }
 46
 47        public bool EnableImages { get; set; }
 48
 49        public bool AddProgramRecordingInfo { get; set; }
 50
 51        public bool EnableUserData { get; set; }
 52
 53        public bool AddCurrentProgram { get; set; }
 54
 55        public bool ContainsField(ItemFields field)
 862056            => Fields.Contains(field);
 57
 58        public int GetImageLimit(ImageType type)
 59        {
 1460            if (EnableImages && ImageTypes.Contains(type))
 61            {
 1462                return ImageTypeLimit;
 63            }
 64
 065            return 0;
 66        }
 67    }
 68}