mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-02 13:33:07 +00:00
36 lines
901 B
C#
36 lines
901 B
C#
namespace CodexPlugin.OverwatchSupport
|
|
{
|
|
public class NameIdMap
|
|
{
|
|
private readonly Dictionary<string, string> map = new Dictionary<string, string>();
|
|
private readonly Dictionary<string, string> shortToLong = new Dictionary<string, string>();
|
|
|
|
public void Add(string name, string peerId)
|
|
{
|
|
map.Add(name, peerId);
|
|
|
|
shortToLong.Add(CodexUtils.ToShortId(peerId), peerId);
|
|
}
|
|
|
|
public string GetPeerId(string name)
|
|
{
|
|
return map[name];
|
|
}
|
|
|
|
public string ReplaceShortIds(string value)
|
|
{
|
|
var result = value;
|
|
foreach (var pair in shortToLong)
|
|
{
|
|
result = result.Replace(pair.Key, pair.Value);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public int Size
|
|
{
|
|
get { return map.Count; }
|
|
}
|
|
}
|
|
}
|