Refactor: Projekt von DigitalData.EmailProfilerDispatcher.Application in DigitalData.EmailProfilerDispatcher umbenannt, um die Struktur zu vereinfachen und die Abstraktion zu verbessern

This commit is contained in:
Developer 02
2024-07-01 14:52:54 +02:00
parent d18b6df9f7
commit a56ede375d
8 changed files with 14 additions and 19 deletions

View File

@@ -0,0 +1,37 @@
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
using System.Reflection;
namespace DigitalData.EmailProfilerDispatcher
{
public static class TemplateExtensions
{
public static string FillTemplate(this string template, params object[] models)
{
foreach (var model in models)
{
var properties = model.GetType().GetProperties();
foreach (var property in properties)
{
var attribute = property.GetCustomAttribute<TemplatePlaceholderAttribute>();
if (attribute != null)
{
var value = property.GetValue(model)?.ToString();
template = template.Replace(attribute.Placeholder, value);
}
}
}
return template;
}
public static string FillTemplate(this string template, Dictionary<string, string> placeholders)
{
foreach (var ph in placeholders)
template = template.Replace(ph.Key, ph.Value);
return template;
}
}
}