jellyfin/MediaBrowser.Model/Dlna/ContainerProfile.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2017-08-04 20:29:34 +00:00
using System;
using System.Collections.Generic;
2014-03-26 15:06:48 +00:00
using System.Xml.Serialization;
2016-12-09 07:23:09 +00:00
using MediaBrowser.Model.Dlna;
2016-12-13 17:04:37 +00:00
using MediaBrowser.Model.Extensions;
2014-03-23 16:42:02 +00:00
2014-04-01 22:23:07 +00:00
namespace MediaBrowser.Model.Dlna
2014-03-23 16:42:02 +00:00
{
public class ContainerProfile
{
2016-12-09 07:23:09 +00:00
[XmlAttribute("type")]
2014-03-23 16:42:02 +00:00
public DlnaProfileType Type { get; set; }
public ProfileCondition[] Conditions { get; set; }
2014-03-26 15:06:48 +00:00
2016-12-09 07:23:09 +00:00
[XmlAttribute("container")]
2014-03-23 16:42:02 +00:00
public string Container { get; set; }
public ContainerProfile()
{
Conditions = new ProfileCondition[] { };
}
2017-08-19 19:43:35 +00:00
public string[] GetContainers()
2017-08-04 06:34:46 +00:00
{
return SplitValue(Container);
}
2017-08-19 19:43:35 +00:00
private static readonly string[] EmptyStringArray = new string[] { };
public static string[] SplitValue(string value)
2014-03-23 16:42:02 +00:00
{
2017-08-19 19:43:35 +00:00
if (string.IsNullOrWhiteSpace(value))
2014-05-08 21:23:24 +00:00
{
2017-08-19 19:43:35 +00:00
return EmptyStringArray;
2014-05-08 21:23:24 +00:00
}
2017-08-19 19:43:35 +00:00
return value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
2014-03-23 16:42:02 +00:00
}
2016-12-13 17:04:37 +00:00
public bool ContainsContainer(string container)
{
2017-08-19 19:43:35 +00:00
var containers = GetContainers();
2016-12-13 17:04:37 +00:00
2017-08-04 06:34:46 +00:00
return ContainsContainer(containers, container);
}
public static bool ContainsContainer(string profileContainers, string inputContainer)
{
return ContainsContainer(SplitValue(profileContainers), inputContainer);
}
2017-08-19 19:43:35 +00:00
public static bool ContainsContainer(string[] profileContainers, string inputContainer)
2017-08-04 06:34:46 +00:00
{
2017-08-19 19:43:35 +00:00
if (profileContainers.Length == 0)
2017-08-04 06:34:46 +00:00
{
return true;
}
var allInputContainers = SplitValue(inputContainer);
foreach (var container in allInputContainers)
{
if (ListHelper.ContainsIgnoreCase(profileContainers, container))
{
return true;
}
}
return false;
2016-12-13 17:04:37 +00:00
}
2014-03-23 16:42:02 +00:00
}
}