Parser: Boolean operations

This commit is contained in:
2019-12-02 03:02:53 +01:00
parent 4f3e5a325e
commit 703639aa07
9 changed files with 198 additions and 9 deletions

View File

@@ -13,5 +13,30 @@
{
return _value;
}
public static bool ConvertToBoolean(object value)
{
if (value is bool)
{
return (bool)value;
}
if (value is decimal)
{
return (decimal)value == 0;
}
if (value is string)
{
string str = (string)value;
if (string.IsNullOrEmpty(str) || str == "0" || str.ToLower() == "false")
{
return false;
}
else
{
return true;
}
}
return false;
}
}
}