aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
blob: 4a814f22a3e4f3c9a51bd1439cd35d30ad46045f (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
using System;
using System.Linq;
using MediaBrowser.Model.Configuration;

namespace MediaBrowser.Model.Extensions;

/// <summary>
/// Extensions for <see cref="LibraryOptions"/>.
/// </summary>
public static class LibraryOptionsExtension
{
    /// <summary>
    /// Get the custom tag delimiters.
    /// </summary>
    /// <param name="options">This LibraryOptions.</param>
    /// <returns>CustomTagDelimiters in char[].</returns>
    public static char[] GetCustomTagDelimiters(this LibraryOptions options)
    {
        ArgumentNullException.ThrowIfNull(options);

        return options.CustomTagDelimiters.Select<string, char?>(x =>
        {
            var isChar = char.TryParse(x, out var c);
            if (isChar)
            {
                return c;
            }

            return null;
        }).Where(x => x is not null).Select(x => x!.Value).ToArray();
    }
}