mlaumcherb/Млаумчерб.Клиент/классы/ArgumentsWithPlaceholders.cs
2024-09-24 16:18:06 +05:00

32 lines
940 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Млаумчерб.Клиент.классы;
public class ArgumentsWithPlaceholders
{
protected List<string> raw_args = new();
public List<string> FillPlaceholders(Dictionary<string, string> values)
{
List<string> result = new();
foreach (var a in raw_args)
{
var f = a;
int begin = a.IndexOf('$');
if (begin != -1)
{
int keyBegin = begin + 2;
int end = a.IndexOf('}', keyBegin);
if (end != -1)
{
var key = a.Substring(keyBegin, end - keyBegin);
if (!values.TryGetValue(key, out var v))
throw new Exception($"can't find value for placeholder '{key}'");
f = v;
}
}
result.Add(f);
}
return result;
}
}