2024-07-26 09:14:46 +02:00
|
|
|
|
namespace CodexPlugin.OverwatchSupport
|
|
|
|
|
|
{
|
|
|
|
|
|
public class NameIdMap
|
|
|
|
|
|
{
|
2024-08-13 13:48:54 +02:00
|
|
|
|
private readonly Dictionary<string, CodexNodeIdentity> map = new Dictionary<string, CodexNodeIdentity>();
|
2024-08-08 10:24:16 +02:00
|
|
|
|
private readonly Dictionary<string, string> shortToLong = new Dictionary<string, string>();
|
2024-07-26 09:14:46 +02:00
|
|
|
|
|
2024-08-13 13:48:54 +02:00
|
|
|
|
public void Add(string name, CodexNodeIdentity identity)
|
2024-07-26 09:14:46 +02:00
|
|
|
|
{
|
2024-08-13 13:48:54 +02:00
|
|
|
|
map.Add(name, identity);
|
2024-08-08 10:24:16 +02:00
|
|
|
|
|
2024-08-13 13:48:54 +02:00
|
|
|
|
shortToLong.Add(CodexUtils.ToShortId(identity.PeerId), identity.PeerId);
|
|
|
|
|
|
shortToLong.Add(CodexUtils.ToShortId(identity.NodeId), identity.NodeId);
|
2024-07-26 09:14:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-13 13:48:54 +02:00
|
|
|
|
public CodexNodeIdentity GetId(string name)
|
2024-07-26 09:14:46 +02:00
|
|
|
|
{
|
|
|
|
|
|
return map[name];
|
|
|
|
|
|
}
|
2024-07-29 10:16:37 +02:00
|
|
|
|
|
2024-08-08 10:24:16 +02:00
|
|
|
|
public string ReplaceShortIds(string value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = value;
|
|
|
|
|
|
foreach (var pair in shortToLong)
|
|
|
|
|
|
{
|
|
|
|
|
|
result = result.Replace(pair.Key, pair.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-29 10:16:37 +02:00
|
|
|
|
public int Size
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return map.Count; }
|
|
|
|
|
|
}
|
2024-07-26 09:14:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|