System.Data.ExpressionNode.IsInteger C# (CSharp) Method

IsInteger() static private method

static private IsInteger ( StorageType type ) : bool
type StorageType
return bool
        internal static bool IsInteger(StorageType type)
        {
            return (type == StorageType.Int16 ||
                type == StorageType.Int32 ||
                type == StorageType.Int64 ||
                type == StorageType.UInt16 ||
                type == StorageType.UInt32 ||
                type == StorageType.UInt64 ||
                type == StorageType.SByte ||
                type == StorageType.Byte);
        }

Usage Example

示例#1
0
        private object EvalFunction(FunctionId id, object[] argumentValues, DataRow row, DataRowVersion version)
        {
            StorageType storageType;

            switch (id)
            {
            case FunctionId.Abs:
                Debug.Assert(_argumentCount == 1, "Invalid argument argumentCount for " + s_funcs[_info]._name + " : " + _argumentCount.ToString(FormatProvider));

                storageType = DataStorage.GetStorageType(argumentValues[0].GetType());
                if (ExpressionNode.IsInteger(storageType))
                {
                    return(Math.Abs((long)argumentValues[0]));
                }
                if (ExpressionNode.IsNumeric(storageType))
                {
                    return(Math.Abs((double)argumentValues[0]));
                }

                throw ExprException.ArgumentTypeInteger(s_funcs[_info]._name, 1);

            case FunctionId.cBool:
                Debug.Assert(_argumentCount == 1, "Invalid argument argumentCount for " + s_funcs[_info]._name + " : " + _argumentCount.ToString(FormatProvider));

                storageType = DataStorage.GetStorageType(argumentValues[0].GetType());
                return(storageType switch
                {
                    StorageType.Boolean => (bool)argumentValues[0],
                    StorageType.Int32 => ((int)argumentValues[0] != 0),
                    StorageType.Double => ((double)argumentValues[0] != 0.0),
                    StorageType.String => bool.Parse((string)argumentValues[0]),
                    _ => throw ExprException.DatatypeConvertion(argumentValues[0].GetType(), typeof(bool)),
                });
All Usage Examples Of System.Data.ExpressionNode::IsInteger