mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 08:23:06 +00:00
35 lines
807 B
C#
35 lines
807 B
C#
namespace BiblioTech.Rewards
|
|
{
|
|
public class CustomReplacement
|
|
{
|
|
private readonly Dictionary<string, string> replacements = new Dictionary<string, string>();
|
|
|
|
public void Add(string from, string to)
|
|
{
|
|
if (replacements.ContainsKey(from))
|
|
{
|
|
replacements[from] = to;
|
|
}
|
|
else
|
|
{
|
|
replacements.Add(from, to);
|
|
}
|
|
}
|
|
|
|
public void Remove(string from)
|
|
{
|
|
replacements.Remove(from);
|
|
}
|
|
|
|
public string Apply(string msg)
|
|
{
|
|
var result = msg;
|
|
foreach (var pair in replacements)
|
|
{
|
|
result.Replace(pair.Key, pair.Value);
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|