Skip to content

Commit

Permalink
switch to GetRuntimeProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Jan 13, 2023
1 parent 1e6a4d6 commit 909d65b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Utils/ParameterUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ public static class ParameterUtils
{
private const string DefaultConcatenationCharacter = ",";

/// <summary>
/// Default <see cref="BindingFlags"/> to search for matching properties
/// </summary>
private const BindingFlags DefaultFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy;

/// <summary>
/// Gets an <see cref="IEnumerable{T}"/> of <see cref="KeyValuePair{TKey,TValue}"/>s from properties with a specified <see cref="IProperty"/>-inheriting attribute.
/// </summary>
internal static IEnumerable<KeyValuePair<string, string>> GetParameter<T>(object host, CultureInfo culture) where T : IProperty
{
foreach (var property in host.GetType().GetProperties(DefaultFlags))
foreach (var property in host.GetType().GetRuntimeProperties())
{
if (!property.CanRead || !(Attribute.GetCustomAttribute(property, typeof(T)) is T attribute))
{
Expand Down Expand Up @@ -96,7 +91,7 @@ internal static object GetSingleParameterObject<T>(object host) where T : Attrib
{
var targetType = typeof(T);
var attributedProperty = host.GetType()
.GetProperties(DefaultFlags)
.GetRuntimeProperties()
.SingleOrDefault(x => Attribute.GetCustomAttribute(x, targetType) is T);

if (attributedProperty == default)
Expand Down

0 comments on commit 909d65b

Please sign in to comment.