Add foundation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user