namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Actors;
///
/// Maps a data connection name to the Akka actor name of its
/// (review 2026-10-21, lane A M2). Shared by (which
/// creates the actor) and the site deploy gate (which rejects a config whose connection names
/// would collide once sanitised), so both always agree on the name.
///
///
/// Every output is a legal Akka path element: ASCII letters and digits plus
/// -_.*+:@&=,!~';() are kept, everything else — spaces, /, #, $
/// and every non-ASCII character — becomes -. The previous sanitiser kept
/// (true for non-ASCII letters, which Akka refuses) and
/// $ (refused as a leading character), so "Ofen Süd" or "$PLC" threw out of
/// Context.ActorOf. The mapping is NOT injective ("PLC A" and "PLC-A" both give
/// "PLC-A"); callers must treat a collision as an error for the later connection.
///
///
public static class ConnectionActorNames
{
private const string KeptSymbols = "-_.*+:@&=,!~';()";
/// The actor name used for .
/// The data connection's configured name.
/// A legal, non-empty Akka actor name.
public static string Sanitize(string connectionName)
{
if (string.IsNullOrEmpty(connectionName))
return "-";
var chars = new char[connectionName.Length];
for (var i = 0; i < chars.Length; i++)
{
var c = connectionName[i];
chars[i] = (c is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9') ||
KeptSymbols.Contains(c)
? c
: '-';
}
return new string(chars);
}
}