parent
af2a5768e7
commit
4b44358af6
1 changed files with 19 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||||
|
// Author: Gockner, Simon |
||||||
|
// Created: 2020-11-13 |
||||||
|
// Copyright(c) 2020 SimonG. All Rights Reserved. |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Linq; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
namespace GBase.Helpers |
||||||
|
{ |
||||||
|
internal static class Attributes |
||||||
|
{ |
||||||
|
public static T GetAttributeFromInheritedInterfaces<T>(this PropertyInfo propertyInfo) where T : Attribute => |
||||||
|
propertyInfo.DeclaringType?.GetInterfaces() |
||||||
|
.SelectMany(i => i.GetProperties().Where(p => p.Name.Equals(propertyInfo.Name))) |
||||||
|
.Select(p => p.GetCustomAttribute<T>()) |
||||||
|
.FirstOrDefault(); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue