Files
Toolkit2/Toolkit.Foundation/TypeExtensions.cs
T
2024-04-13 11:29:32 +01:00

18 lines
366 B
C#

using System.Reflection;
namespace Toolkit.Foundation;
public static class TypeExtensions
{
public static TAttribute? GetAttribute<TAttribute>(this Type type)
where TAttribute : Attribute
{
if (type.GetCustomAttribute<TAttribute>() is TAttribute attribute)
{
return attribute;
}
return null;
}
}