Rename class and update namespace for placeholder logic

Renamed the ReflectionExtensions class to PlaceholderExtensions and moved it from the ReC.Domain.Extensions namespace to ReC.Application.Common.Behaviors.InvokeAction to better reflect its purpose and location within the project structure.
This commit is contained in:
2026-03-26 13:48:16 +01:00
parent 56730c0d4e
commit 2ae5251550

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;
namespace ReC.Application.Common.Behaviors.InvokeAction;
public static class PlaceholderExtensions
{
/// <summary>
/// Gets the value of a property by its column name defined in <see cref="ColumnAttribute"/>.
/// Returns <c>null</c> if no property with the given column name exists.
/// </summary>
public static object? GetValueByColumnName<T>(this T obj, string columnName) where T : class
{
var property = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
.FirstOrDefault(p => p.GetCustomAttribute<ColumnAttribute>()?.Name == columnName);
return property?.GetValue(obj);
}
}