diff --git a/GBase/Helpers/Attributes.cs b/GBase/Helpers/Attributes.cs new file mode 100644 index 0000000..1b4e3a0 --- /dev/null +++ b/GBase/Helpers/Attributes.cs @@ -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(this PropertyInfo propertyInfo) where T : Attribute => + propertyInfo.DeclaringType?.GetInterfaces() + .SelectMany(i => i.GetProperties().Where(p => p.Name.Equals(propertyInfo.Name))) + .Select(p => p.GetCustomAttribute()) + .FirstOrDefault(); + } +} \ No newline at end of file