nft-faucet/NftFaucet/Extensions/TypeExtensions.cs
2022-04-03 21:23:01 +02:00

15 lines
408 B
C#

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;
}
}