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)),
});