Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed cbool() and added overloaded functions to handle conversions …

…from type string.
  • Loading branch information...
commit 39565d3df6bccd03398a87e0ec1ce43efe9ccda4 1 parent f014364
@ajp8164 ajp8164 authored
Showing with 46 additions and 6 deletions.
  1. +46 −6 mediaportal/Core/guilib/Functions.cs
View
52 mediaportal/Core/guilib/Functions.cs
@@ -179,12 +179,6 @@ public static DateTime ConvertToDate(object value)
return Convert.ToDateTime(value);
}
- [XMLSkinFunction("cbool")]
- public static bool ConvertToBool(object value)
- {
- return Convert.ToBoolean(value);
- }
-
#endregion
#region Conditionals
@@ -195,12 +189,24 @@ public static object Iif(bool condition, object truePart, object falsePart)
return condition ? truePart : falsePart;
}
+ [XMLSkinFunction("iif")]
+ public static object Iif(string condition, object truePart, object falsePart)
+ {
+ return Iif(bool.Parse(condition), truePart, falsePart);
+ }
+
[XMLSkinFunction("choose")]
public static object Choose(int index, params object[] values)
{
return values[index];
}
+ [XMLSkinFunction("choose")]
+ public static object Choose(string index, params object[] values)
+ {
+ return Choose(int.Parse(index), values);
+ }
+
[XMLSkinFunction("switch")]
public static object Switch(params object[] args)
{
@@ -330,6 +336,12 @@ public static bool Not(bool condition)
return !condition;
}
+ [XMLSkinFunction("not")]
+ public static bool Not(string condition)
+ {
+ return Not(bool.Parse(condition));
+ }
+
[XMLSkinFunction("and")]
public static bool And(params bool[] conditions)
{
@@ -343,6 +355,20 @@ public static bool And(params bool[] conditions)
return true;
}
+ [XMLSkinFunction("and")]
+ public static bool And(params object[] conditions)
+ {
+ bool[] bConditions = new bool[conditions.Length];
+ for (int i = 0; i < conditions.Length; i++)
+ {
+ if (conditions[i].GetType() == typeof(string))
+ {
+ bConditions[i] = bool.Parse(conditions[i].ToString());
+ }
+ }
+ return And(bConditions);
+ }
+
[XMLSkinFunction("or")]
public static bool Or(params bool[] conditions)
{
@@ -356,6 +382,20 @@ public static bool Or(params bool[] conditions)
return false;
}
+ [XMLSkinFunction("or")]
+ public static bool Or(params object[] conditions)
+ {
+ bool[] bConditions = new bool[conditions.Length];
+ for (int i = 0; i < conditions.Length; i++)
+ {
+ if (conditions[i].GetType() == typeof(string))
+ {
+ bConditions[i] = bool.Parse(conditions[i].ToString());
+ }
+ }
+ return Or(bConditions);
+ }
+
#endregion
#region Other functions
Please sign in to comment.
Something went wrong with that request. Please try again.