Пример #1
0
 public static bool ToBoolean(object value)
 {
     if (DataStorageHelper.IsUnknown(value))
     {
         return(false);
     }
     if (value is bool)
     {
         return((bool)value);
     }
     if (value is SqlBoolean)
     {
         return(((SqlBoolean)value).IsTrue);
     }
     if (!(value is string))
     {
         throw InvalidExpressionException.DatavalueConvertion(value, typeof(bool), (Exception)null);
     }
     try
     {
         return(bool.Parse((string)value));
     }
     catch (Exception ex)
     {
         throw InvalidExpressionException.DatavalueConvertion(value, typeof(bool), ex);
     }
 }
Пример #2
0
 public static bool ToBoolean(object value)
 {
     if (IsUnknown(value))
     {
         return(false);
     }
     if (value is bool)
     {
         return((bool)value);
     }
     if (value is SqlBoolean)
     {
         SqlBoolean flag2 = (SqlBoolean)value;
         return(flag2.IsTrue);
     }
     if (value is string)
     {
         try
         {
             return(bool.Parse((string)value));
         }
         catch (Exception exception)
         {
             throw InvalidExpressionException.DatavalueConvertion(value, typeof(bool), exception);
         }
     }
     throw InvalidExpressionException.DatavalueConvertion(value, typeof(bool), null);
 }
Пример #3
0
 public virtual object CBool(object value)
 {
     if (DBNull.Value == value)
     {
         value = (object)null;
     }
     try
     {
         return((object)Convert.ToBoolean(value));
     }
     catch (Exception ex)
     {
         throw InvalidExpressionException.DatavalueConvertion(value, typeof(bool), ex);
     }
 }