diff --git a/mustache-sharp/EqTagDefinition.cs b/mustache-sharp/EqTagDefinition.cs index cf60516..8086266 100644 --- a/mustache-sharp/EqTagDefinition.cs +++ b/mustache-sharp/EqTagDefinition.cs @@ -58,7 +58,7 @@ namespace Mustache { } - if ((condition is double || condition is int) && (targetValue is double || targetValue is int) ) { + if ((condition is double || condition is int) || (targetValue is double || targetValue is int) ) { return Convert.ToDouble(condition) == Convert.ToDouble(targetValue); } diff --git a/mustache-sharp/GtTagDefinition.cs b/mustache-sharp/GtTagDefinition.cs index 1c54107..25980a9 100644 --- a/mustache-sharp/GtTagDefinition.cs +++ b/mustache-sharp/GtTagDefinition.cs @@ -55,12 +55,12 @@ namespace Mustache { return false; } - if ((condition is double || condition is int) && (targetValue is double || targetValue is int)) { + try { return Convert.ToDouble(condition) > Convert.ToDouble(targetValue); + } catch (Exception exception) { + return false; } - - return false; } /// diff --git a/mustache-sharp/GteTagDefinition.cs b/mustache-sharp/GteTagDefinition.cs index c63b7d9..eb407ec 100644 --- a/mustache-sharp/GteTagDefinition.cs +++ b/mustache-sharp/GteTagDefinition.cs @@ -55,11 +55,14 @@ namespace Mustache { return false; } - if ((condition is double || condition is int) && (targetValue is double || targetValue is int)) { + try { return Convert.ToDouble(condition) >= Convert.ToDouble(targetValue); + } catch (Exception exception) { + return false; } + return false; } diff --git a/mustache-sharp/LtTagDefinition.cs b/mustache-sharp/LtTagDefinition.cs index 7d38a17..8a70479 100644 --- a/mustache-sharp/LtTagDefinition.cs +++ b/mustache-sharp/LtTagDefinition.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; namespace Mustache { @@ -55,12 +56,14 @@ namespace Mustache { return false; } - if ((condition is double || condition is int) && (targetValue is double || targetValue is int)) { + try { return Convert.ToDouble(condition) < Convert.ToDouble(targetValue); } + catch (Exception exception) { + return false; + } - return false; } /// diff --git a/mustache-sharp/LteTagDefinition.cs b/mustache-sharp/LteTagDefinition.cs index 505659b..32c9183 100644 --- a/mustache-sharp/LteTagDefinition.cs +++ b/mustache-sharp/LteTagDefinition.cs @@ -55,10 +55,12 @@ namespace Mustache { return false; } - if ((condition is double || condition is int) && (targetValue is double || targetValue is int)) { + try { return Convert.ToDouble(condition) <= Convert.ToDouble(targetValue); + } catch (Exception exception) { + return false; } - + return false; }