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.
This commit is contained in:
Loretta 2026-02-23 18:21:20 +01:00
parent 9fc12e2fcc
commit d5a908a46f
1 changed files with 3 additions and 0 deletions

View File

@ -78,9 +78,12 @@ public class MgGridDataColumn : DxGridDataColumn
internal static string BuildUrlFromTemplate(string template, object? dataItem) internal static string BuildUrlFromTemplate(string template, object? dataItem)
{ {
if (dataItem == null) return template; if (dataItem == null) return template;
return Regex.Replace(template, "{([^}]+)}", match => return Regex.Replace(template, "{([^}]+)}", match =>
{ {
var propName = match.Groups[1].Value; 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); var prop = dataItem.GetType().GetProperty(propName);
if (prop != null) if (prop != null)
{ {