mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-19 23:28:15 +08:00
20 lines
656 B
C#
20 lines
656 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Dapper.Contrib.Extensions
|
|
{
|
|
public static class TypeExtension
|
|
{
|
|
public static Boolean IsAnonymousType(this Type type)
|
|
{
|
|
if (type == null) return false;
|
|
|
|
var hasCompilerGeneratedAttribute = type.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Count() > 0;
|
|
var nameContainsAnonymousType = type.FullName.Contains("AnonymousType");
|
|
var isAnonymousType = hasCompilerGeneratedAttribute && nameContainsAnonymousType;
|
|
|
|
return isAnonymousType;
|
|
}
|
|
}
|
|
} |