32 lines
940 B
C#
32 lines
940 B
C#
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;
|
||
}
|
||
}
|