consolidate methods
This commit is contained in:
parent
d50ffcbfb2
commit
b786cca9da
|
@ -42,16 +42,9 @@ namespace MediaBrowser.Model.Dlna
|
|||
return SplitValue(Codec);
|
||||
}
|
||||
|
||||
public List<string> GetContainers()
|
||||
{
|
||||
return SplitValue(Container);
|
||||
}
|
||||
|
||||
private bool ContainsContainer(string container)
|
||||
{
|
||||
List<string> containers = GetContainers();
|
||||
|
||||
return containers.Count == 0 || ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty);
|
||||
return ContainerProfile.ContainsContainer(Container, container);
|
||||
}
|
||||
|
||||
public bool ContainsCodec(string codec, string container)
|
||||
|
|
|
@ -20,11 +20,16 @@ namespace MediaBrowser.Model.Dlna
|
|||
}
|
||||
|
||||
public List<string> GetContainers()
|
||||
{
|
||||
return SplitValue(Container);
|
||||
}
|
||||
|
||||
private static List<string> SplitValue(string value)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (string i in (Container ?? string.Empty).Split(','))
|
||||
foreach (string i in (value ?? string.Empty).Split(','))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
||||
if (!string.IsNullOrWhiteSpace(i)) list.Add(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -33,7 +38,32 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
List<string> containers = GetContainers();
|
||||
|
||||
return containers.Count == 0 || ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty);
|
||||
return ContainsContainer(containers, container);
|
||||
}
|
||||
|
||||
public static bool ContainsContainer(string profileContainers, string inputContainer)
|
||||
{
|
||||
return ContainsContainer(SplitValue(profileContainers), inputContainer);
|
||||
}
|
||||
|
||||
public static bool ContainsContainer(List<string> profileContainers, string inputContainer)
|
||||
{
|
||||
if (profileContainers.Count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var allInputContainers = SplitValue(inputContainer);
|
||||
|
||||
foreach (var container in allInputContainers)
|
||||
{
|
||||
if (ListHelper.ContainsIgnoreCase(profileContainers, container))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,27 +19,9 @@ namespace MediaBrowser.Model.Dlna
|
|||
[XmlAttribute("type")]
|
||||
public DlnaProfileType Type { get; set; }
|
||||
|
||||
public List<string> GetContainers()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (string i in (Container ?? string.Empty).Split(','))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool SupportsContainer(string container)
|
||||
{
|
||||
var all = GetContainers();
|
||||
|
||||
// Only allow unknown container if the profile is all inclusive
|
||||
if (string.IsNullOrWhiteSpace(container))
|
||||
{
|
||||
return all.Count == 0;
|
||||
}
|
||||
|
||||
return all.Count == 0 || all.Contains(container, StringComparer.OrdinalIgnoreCase);
|
||||
return ContainerProfile.ContainsContainer(Container, container);
|
||||
}
|
||||
|
||||
public List<string> GetAudioCodecs()
|
||||
|
|
Loading…
Reference in New Issue
Block a user