Browse Source

Create TypeExtensions.cs

pull/165/head
Ionite 1 year ago
parent
commit
765d94e010
No known key found for this signature in database
  1. 15
      StabilityMatrix.Core/Extensions/TypeExtensions.cs

15
StabilityMatrix.Core/Extensions/TypeExtensions.cs

@ -0,0 +1,15 @@
using System.Reflection;
namespace StabilityMatrix.Core.Extensions;
public static class TypeExtensions
{
/// <summary>
/// Get all properties marked with an attribute of type <see cref="TAttribute"/>
/// </summary>
public static IEnumerable<PropertyInfo> GetPropertiesWithAttribute<TAttribute>(this Type type)
where TAttribute : Attribute
{
return type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(TAttribute)));
}
}
Loading…
Cancel
Save