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:
parent
9fc12e2fcc
commit
d5a908a46f
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue