nft-faucet/NftFaucet/Extensions/TypeExtensions.cs

15 lines
408 B
C#
Raw Normal View History

2022-03-31 22:16:43 +02:00
using System.Reflection;
namespace NftFaucet.Extensions;
public static class TypeExtensions
{
public static TAttribute GetAttribute<TAttribute>(this MemberInfo memberInfo)
where TAttribute : Attribute
{
var customAttributes = memberInfo?.GetCustomAttributes(false);
var attribute = customAttributes?.OfType<TAttribute>().SingleOrDefault();
return attribute;
}
}