aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Common/EpisodeExpression.cs
blob: f60f7e84b1cf10ad53cf03a472889d17c4e42d0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma warning disable CS1591
#pragma warning disable SA1600

using System;
using System.Text.RegularExpressions;

namespace Emby.Naming.Common
{
    public class EpisodeExpression
    {
        private string _expression;
        private Regex _regex;

        public EpisodeExpression(string expression, bool byDate)
        {
            Expression = expression;
            IsByDate = byDate;
            DateTimeFormats = Array.Empty<string>();
            SupportsAbsoluteEpisodeNumbers = true;
        }

        public EpisodeExpression(string expression)
            : this(expression, false)
        {
        }

        public EpisodeExpression()
            : this(null)
        {
        }

        public string Expression
        {
            get => _expression;
            set
            {
                _expression = value;
                _regex = null;
            }
        }

        public bool IsByDate { get; set; }

        public bool IsOptimistic { get; set; }

        public bool IsNamed { get; set; }

        public bool SupportsAbsoluteEpisodeNumbers { get; set; }

        public string[] DateTimeFormats { get; set; }

        public Regex Regex => _regex ?? (_regex = new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled));
    }
}