Skip to content

Commit

Permalink
Adopt TypeCode for "IsNumeric" type extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
skrysmanski committed Jul 9, 2024
1 parent d79e279 commit 0afccb0
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/AppMotor.Core/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ public static bool IsNumericType(this Type type, bool includeNullables)

if (type.IsPrimitive)
{
switch (type.FullName)
switch (Type.GetTypeCode(type))
{
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 TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Int64:
case TypeCode.UInt64:
return true;

case "System.Single":
case "System.Double":
case TypeCode.Single:
case TypeCode.Double:
return true;

default:
Expand Down Expand Up @@ -150,16 +150,16 @@ public static bool IsNumericIntegerType(this Type type, bool includeNullables)

if (type.IsPrimitive)
{
switch (type.FullName)
switch (Type.GetTypeCode(type))
{
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 TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Int64:
case TypeCode.UInt64:
return true;

default:
Expand Down Expand Up @@ -210,10 +210,10 @@ public static bool IsNumericFloatType(this Type type, bool includeNullables)

if (type.IsPrimitive)
{
switch (type.FullName)
switch (Type.GetTypeCode(type))
{
case "System.Single":
case "System.Double":
case TypeCode.Single:
case TypeCode.Double:
return true;

default:
Expand Down

0 comments on commit 0afccb0

Please sign in to comment.