Move GetCustomTagDelimiters to Extension

This commit is contained in:
gnattu
2024-09-24 12:36:05 +08:00
parent 00ca4abbe1
commit 0ffddacf11
3 changed files with 33 additions and 14 deletions

View File

@@ -0,0 +1,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();
}
}