From d5a908a46ff23b43bf37a04df2cb32ee3bbb34e7 Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 23 Feb 2026 18:21:20 +0100 Subject: [PATCH] Update BuildUrlFromTemplate to use Regex with lambda Refactored BuildUrlFromTemplate to use Regex.Replace with a lambda for dynamic property replacement in template strings. Added a TODO comment about optimizing with cached delegates. --- AyCode.Blazor.Components/Components/Grids/MgGridDataColumn.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AyCode.Blazor.Components/Components/Grids/MgGridDataColumn.cs b/AyCode.Blazor.Components/Components/Grids/MgGridDataColumn.cs index a0083c2..93b0746 100644 --- a/AyCode.Blazor.Components/Components/Grids/MgGridDataColumn.cs +++ b/AyCode.Blazor.Components/Components/Grids/MgGridDataColumn.cs @@ -78,9 +78,12 @@ public class MgGridDataColumn : DxGridDataColumn internal static string BuildUrlFromTemplate(string template, object? dataItem) { if (dataItem == null) return template; + return Regex.Replace(template, "{([^}]+)}", match => { var propName = match.Groups[1].Value; + + //TODO: delegate-et kéne használni és cache-elni egy dictionary-ba! - J. var prop = dataItem.GetType().GetProperty(propName); if (prop != null) {