LibraryOptionsExtension.cs 970 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Linq;
  3. using MediaBrowser.Model.Configuration;
  4. namespace MediaBrowser.Model.Extensions;
  5. /// <summary>
  6. /// Extensions for <see cref="LibraryOptions"/>.
  7. /// </summary>
  8. public static class LibraryOptionsExtension
  9. {
  10. /// <summary>
  11. /// Get the custom tag delimiters.
  12. /// </summary>
  13. /// <param name="options">This LibraryOptions.</param>
  14. /// <returns>CustomTagDelimiters in char[].</returns>
  15. public static char[] GetCustomTagDelimiters(this LibraryOptions options)
  16. {
  17. ArgumentNullException.ThrowIfNull(options);
  18. var delimiterList = options.CustomTagDelimiters.Select<string, char?>(x =>
  19. {
  20. var isChar = char.TryParse(x, out var c);
  21. if (isChar)
  22. {
  23. return c;
  24. }
  25. return null;
  26. }).Where(x => x is not null).Select(x => x!.Value).ToList();
  27. delimiterList.Add('\0');
  28. return delimiterList.ToArray();
  29. }
  30. }