Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 3ef5b2a

Browse files
committed
Add IsSystemType extension method
1 parent d8caf69 commit 3ef5b2a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/ServiceStack.Text/StringExtensions.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,17 +783,20 @@ public static string ToNullIfEmpty(this string text)
783783
public static bool IsUserType(this Type type)
784784
{
785785
return type.IsClass()
786-
&& type.Namespace != null
787-
&& !type.Namespace.StartsWith("System")
788-
&& type.Name.IndexOfAny(SystemTypeChars) == -1;
786+
&& !type.IsSystemType();
789787
}
790788

791789
public static bool IsUserEnum(this Type type)
792790
{
793791
return type.IsEnum()
794-
&& type.Namespace != null
795-
&& !type.Namespace.StartsWith("System")
796-
&& type.Name.IndexOfAny(SystemTypeChars) == -1;
792+
&& !type.IsSystemType();
793+
}
794+
795+
public static bool IsSystemType(this Type type)
796+
{
797+
return type.Namespace == null
798+
|| type.Namespace.StartsWith("System")
799+
|| type.Name.IndexOfAny(SystemTypeChars) >= 0;
797800
}
798801

799802
public static bool IsInt(this string text)

0 commit comments

Comments
 (0)