Skip to content

Commit b4c5b97

Browse files
committed
Add GetAttribute method to IBaseMemberInfo (MemberAccessor)
1 parent 1051a32 commit b4c5b97

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

KludgeBox/KludgeBox.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Minor - добавление новых фич, запланированое плавное устаревание API
99
Patch - небольшие фиксы и незначительный функционал
1010
-->
11-
<GeneralVersion>3.2.0</GeneralVersion>
11+
<GeneralVersion>3.2.1</GeneralVersion>
1212

1313
<!--
1414
Пререлизный тег, на случай, когда надо зарелизить что-то, что не должно попасть в релиз

KludgeBox/Reflection/Access/IBaseMemberInfo.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ public interface IBaseMemberInfo
99
IReadOnlyList<Attribute> Attributes { get; }
1010
bool IsPublic { get; }
1111

12+
Attribute GetAttribute<TAttribute>() where TAttribute : Attribute
13+
{
14+
return GetAttribute(typeof(TAttribute));
15+
}
16+
Attribute GetAttribute(Type attributeType)
17+
{
18+
if (TryGetAttribute(attributeType, out Attribute attribute))
19+
{
20+
return attribute;
21+
}
22+
return null;
23+
}
24+
1225
bool HasAttribute(Type attributeType)
1326
{
1427
return Attributes.Any(attr => attr.GetType() == attributeType);

0 commit comments

Comments
 (0)