aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dlna/ConditionProcessor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model/Dlna/ConditionProcessor.cs')
-rw-r--r--MediaBrowser.Model/Dlna/ConditionProcessor.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
index 66c3e0b19..89b844ae5 100644
--- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs
+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
@@ -175,6 +175,35 @@ namespace MediaBrowser.Model.Dlna
return false;
}
+
+ private bool IsConditionSatisfied(ProfileCondition condition, float? currentValue)
+ {
+ if (!currentValue.HasValue)
+ {
+ // If the value is unknown, it satisfies if not marked as required
+ return !condition.IsRequired;
+ }
+
+ float expected;
+ if (FloatHelper.TryParseCultureInvariant(condition.Value, out expected))
+ {
+ switch (condition.Condition)
+ {
+ case ProfileConditionType.Equals:
+ return currentValue.Value.Equals(expected);
+ case ProfileConditionType.GreaterThanEqual:
+ return currentValue.Value >= expected;
+ case ProfileConditionType.LessThanEqual:
+ return currentValue.Value <= expected;
+ case ProfileConditionType.NotEquals:
+ return !currentValue.Value.Equals(expected);
+ default:
+ throw new InvalidOperationException("Unexpected ProfileConditionType");
+ }
+ }
+
+ return false;
+ }
private bool IsConditionSatisfied(ProfileCondition condition, double? currentValue)
{