diff --git a/ICD.Common.Utils/Extensions/TypeExtensions.cs b/ICD.Common.Utils/Extensions/TypeExtensions.cs index 11e5fc9..9810b26 100644 --- a/ICD.Common.Utils/Extensions/TypeExtensions.cs +++ b/ICD.Common.Utils/Extensions/TypeExtensions.cs @@ -92,6 +92,20 @@ namespace ICD.Common.Utils.Extensions return !extends.IsValueType || Nullable.GetUnderlyingType(extends) != null; } + /// + /// Returns true if the type is anonymous. + /// + /// + /// + public static bool IsAnonymous([NotNull] this Type type) + { + if (type == null) + throw new ArgumentNullException("type"); + + return (type.Name.Contains("AnonymousType") || type.Name.Contains("AnonType")) && + (type.Name.StartsWith("<>") || type.Name.StartsWith("VB$")); + } + /// /// Returns true if the given type is a numeric type. ///