ContainerProfile.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma warning disable CA1819 // Properties should not return arrays
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Xml.Serialization;
  5. using MediaBrowser.Model.Extensions;
  6. namespace MediaBrowser.Model.Dlna;
  7. /// <summary>
  8. /// Defines the <see cref="ContainerProfile"/>.
  9. /// </summary>
  10. public class ContainerProfile
  11. {
  12. /// <summary>
  13. /// Gets or sets the <see cref="DlnaProfileType"/> which this container must meet.
  14. /// </summary>
  15. [XmlAttribute("type")]
  16. public DlnaProfileType Type { get; set; }
  17. /// <summary>
  18. /// Gets or sets the list of <see cref="ProfileCondition"/> which this container will be applied to.
  19. /// </summary>
  20. public ProfileCondition[] Conditions { get; set; } = [];
  21. /// <summary>
  22. /// Gets or sets the container(s) which this container must meet.
  23. /// </summary>
  24. [XmlAttribute("container")]
  25. public string? Container { get; set; }
  26. /// <summary>
  27. /// Gets or sets the sub container(s) which this container must meet.
  28. /// </summary>
  29. [XmlAttribute("subcontainer")]
  30. public string? SubContainer { get; set; }
  31. /// <summary>
  32. /// Returns true if an item in <paramref name="container"/> appears in the <see cref="Container"/> property.
  33. /// </summary>
  34. /// <param name="container">The item to match.</param>
  35. /// <param name="useSubContainer">Consider subcontainers.</param>
  36. /// <returns>The result of the operation.</returns>
  37. public bool ContainsContainer(ReadOnlySpan<char> container, bool useSubContainer = false)
  38. {
  39. var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ? SubContainer : Container;
  40. return ContainerHelper.ContainsContainer(containerToCheck, container);
  41. }
  42. }