adding extension methods (#1938)

This commit is contained in:
James Frowen 2020-05-30 14:43:32 +01:00 committed by GitHub
parent 26c02199ba
commit 3a35b0e9de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,6 +148,26 @@ public static CustomAttribute GetCustomAttribute(this ICustomAttributeProvider m
}
return null;
}
public static CustomAttribute GetCustomAttribute(this ICustomAttributeProvider method, TypeReference attribute)
{
foreach (CustomAttribute ca in method.CustomAttributes)
{
if (ca.AttributeType.FullName == attribute.FullName)
return ca;
}
return null;
}
public static bool HasCustomAttribute(this ICustomAttributeProvider attributeProvider, string attributeName)
{
foreach (CustomAttribute ca in attributeProvider.CustomAttributes)
{
if (ca.AttributeType.FullName == attributeName)
return true;
}
return false;
}
public static bool HasCustomAttribute(this ICustomAttributeProvider attributeProvider, TypeReference attribute)
{