Deveel.Data.Client.DeveelDbConnectionStringBuilder.ToBoolean C# (CSharp) Method

ToBoolean() private static method

private static ToBoolean ( object value ) : bool
value object
return bool
        private static bool ToBoolean(object value)
        {
            if (value == null)
                throw new ArgumentException();

            if (value is bool)
                return (bool)value;

            if (value is string) {
                string s = value.ToString().ToUpper();
                if (s == "YES" || s == "ENABLED" ||
                    s == "TRUE" || s == "ON")
                    return true;
                if (s == "NO" || s == "DISABLED" ||
                    s == "FALSE" || s == "OFF")
                    return false;
            }

            if (value is IConvertible)
                return (value as IConvertible).ToBoolean(CultureInfo.InvariantCulture);

            throw new ArgumentException();
        }