mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +00:00
feat: Added extension method for determining if a type is Anonymous
This commit is contained in:
parent
b29ae4c8c8
commit
08aeba756a
1 changed files with 14 additions and 0 deletions
|
|
@ -92,6 +92,20 @@ namespace ICD.Common.Utils.Extensions
|
||||||
return !extends.IsValueType || Nullable.GetUnderlyingType(extends) != null;
|
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>
|
/// <summary>
|
||||||
/// Returns true if the given type is a numeric type.
|
/// Returns true if the given type is a numeric type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue