System.Data.ExpressionNode.IsNumeric C# (CSharp) Méthode

IsNumeric() static private méthode

static private IsNumeric ( StorageType type ) : bool
type StorageType
Résultat bool
        internal static bool IsNumeric(StorageType type)
        {
            return (IsFloat(type) ||
                   IsInteger(type));
        }

Usage Example

Exemple #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::IsNumeric