aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-04 02:34:46 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-04 02:34:46 -0400
commitb786cca9da42b6caa1e2b1f2d4fa7ac0c0c0a984 (patch)
tree33064ba41171076065ac023a4dff337a59bd8763
parentd50ffcbfb22e1b22c80c033606601f22b1de66d2 (diff)
consolidate methods
-rw-r--r--MediaBrowser.Model/Dlna/CodecProfile.cs9
-rw-r--r--MediaBrowser.Model/Dlna/ContainerProfile.cs36
-rw-r--r--MediaBrowser.Model/Dlna/DirectPlayProfile.cs20
3 files changed, 35 insertions, 30 deletions
diff --git a/MediaBrowser.Model/Dlna/CodecProfile.cs b/MediaBrowser.Model/Dlna/CodecProfile.cs
index e04e04d21..979cd343f 100644
--- a/MediaBrowser.Model/Dlna/CodecProfile.cs
+++ b/MediaBrowser.Model/Dlna/CodecProfile.cs
@@ -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)
diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs
index 35d7ada6b..a8f203e22 100644
--- a/MediaBrowser.Model/Dlna/ContainerProfile.cs
+++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs
@@ -21,10 +21,15 @@ 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;
}
}
}
diff --git a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs b/MediaBrowser.Model/Dlna/DirectPlayProfile.cs
index df511b0da..d99501875 100644
--- a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs
+++ b/MediaBrowser.Model/Dlna/DirectPlayProfile.cs
@@ -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()