diff --git a/StabilityMatrix.Core/Extensions/TypeExtensions.cs b/StabilityMatrix.Core/Extensions/TypeExtensions.cs new file mode 100644 index 00000000..8806868b --- /dev/null +++ b/StabilityMatrix.Core/Extensions/TypeExtensions.cs @@ -0,0 +1,15 @@ +using System.Reflection; + +namespace StabilityMatrix.Core.Extensions; + +public static class TypeExtensions +{ + /// + /// Get all properties marked with an attribute of type + /// + public static IEnumerable GetPropertiesWithAttribute(this Type type) + where TAttribute : Attribute + { + return type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(TAttribute))); + } +}