mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver Extensions: HasCustomAttribute uses Linq to simplify code
This commit is contained in:
parent
467d9e834f
commit
2ea787f4fc
@ -179,12 +179,8 @@ public static CustomAttribute GetCustomAttribute(this ICustomAttributeProvider m
|
||||
|
||||
public static bool HasCustomAttribute(this ICustomAttributeProvider attributeProvider, TypeReference attribute)
|
||||
{
|
||||
foreach (CustomAttribute ca in attributeProvider.CustomAttributes)
|
||||
{
|
||||
if (ca.AttributeType.FullName == attribute.FullName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// Linq allocations don't matter in weaver
|
||||
return attributeProvider.CustomAttributes.Any(attr => attr.AttributeType.FullName == attribute.FullName);
|
||||
}
|
||||
|
||||
public static T GetField<T>(this CustomAttribute ca, string field, T defaultValue)
|
||||
|
Loading…
Reference in New Issue
Block a user