mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Added extension method for determining if a type is Anonymous
This commit is contained in:
@@ -92,6 +92,20 @@ namespace ICD.Common.Utils.Extensions
|
||||
return !extends.IsValueType || Nullable.GetUnderlyingType(extends) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the type is anonymous.
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
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$"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the given type is a numeric type.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user