src/AppMotor.Core/Extensions/TypeExtensions.cs
/// <summary>
/// Returns whether this type is a (scalar) numeric type. This list includes <c>byte</c>
/// and <c>sbyte</c> as well as <see cref="BigInteger"/>. However <see cref="Complex"/>
/// is excluded.
/// </summary>
/// <remarks>
/// This method checks the type's full name but ignores the type's assembly. It's therefor
/// not 100% fool proof. However, the chance that someone recreates one of the system types
/// which then should not be a numeric value is rather slim (or even impossible?).
/// </remarks>
/// <seealso cref="IsNumericIntegerType"/>
/// <seealso cref="IsNumericFloatType"/>
Returns whether this type is a (scalar) numeric type. This list includes bytesbyte. However
is excluded.
Returns whether this type is a ( scalar ) numeric type . This list includes bytesbyte . However is excluded .
[PublicAPI, Pure]
    public static bool IsNumericType(this Type type)
    {
        Validate.ArgumentWithName(nameof(type)).IsNotNull(type);
        switch (type.FullName)
        {
            case "System.Byte":
            case "System.SByte":
            case "System.Int16":
            case "System.UInt16":
            case "System.Int32":
            case "System.UInt32":
            case "System.Int64":
            case "System.UInt64":
            case "System.Numerics.BigInteger":
                return true;
            case "System.Single":
            case "System.Double":
            case "System.Decimal":
                return true;
            default:
                return false;
        }
    }
[ PublicAPI , Pure ] public static bool IsNumericType ( this Type type ) { Validate . ArgumentWithName ( nameof ( type ) ) . IsNotNull ( type ) ; switch ( type . FullName ) { case " " : case " " : case " " : case " " : case " " : case " " : case " " : case " " : case " " : return true ; case " " : case " " : case " " : return true ; default : return false ; } }
Returns whether this type is a (scalar) numeric type.
Returns whether this type is a ( scalar ) numeric type .
Type
this
remarks
This method checks the type's full name but ignores the type's assembly. It's therefor
not 100% fool proof. However, the chance that someone recreates one of the system types
which then should not be a numeric value is rather slim (or even impossible?).
This method checks the type ' s full name but ignores the type ' s assembly . It ' s therefor not 100% fool proof . However the chance that someone recreates one of the system types which then should not be a numeric value is rather slim ( or even impossible? ) .
seealso
None
seealso
None