refactor: rename ScadaLink → ZB.MOM.WW.ScadaBridge (code + projects + namespaces)
Solution + 23 src projects + 26 test projects renamed; folders, csproj, namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated. ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated. SQL roles/logins, LDAP domains, CLI command name, and CLI config dir (~/.scadalink → ~/.scadabridge) also renamed. Build green; 5 Host.Tests fail awaiting SQL login rename in next commit. Pre-existing StaleTagMonitor timing flakes unchanged. Rename script committed at tools/rename-to-scadabridge.sh.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol;
|
||||
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer;
|
||||
|
||||
/// <summary>
|
||||
/// WP-34: Default factory that resolves protocol type strings to IDataConnection adapters.
|
||||
/// Protocol extensibility: register new adapters via the constructor or AddAdapter method.
|
||||
/// </summary>
|
||||
public class DataConnectionFactory : IDataConnectionFactory
|
||||
{
|
||||
private readonly Dictionary<string, Func<IDictionary<string, string>, IDataConnection>> _factories = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="DataConnectionFactory"/> with default OPC UA global options.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">Logger factory used when creating protocol adapters.</param>
|
||||
public DataConnectionFactory(ILoggerFactory loggerFactory)
|
||||
: this(loggerFactory, Options.Create(new OpcUaGlobalOptions())) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="DataConnectionFactory"/> with explicit OPC UA global options.
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">Logger factory used when creating protocol adapters.</param>
|
||||
/// <param name="opcUaGlobalOptions">Global OPC UA options applied to all OPC UA connections created by this factory.</param>
|
||||
public DataConnectionFactory(ILoggerFactory loggerFactory, IOptions<OpcUaGlobalOptions> opcUaGlobalOptions)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
var globalOptions = opcUaGlobalOptions.Value;
|
||||
|
||||
// Register built-in protocols.
|
||||
// DataConnectionLayer-014: pass the ILoggerFactory into RealOpcUaClientFactory so
|
||||
// the RealOpcUaClient it builds gets a real logger — without it the DCL-012
|
||||
// auto-accept-certificate security warning is silently discarded by NullLogger.
|
||||
RegisterAdapter("OpcUa", details => new OpcUaDataConnection(
|
||||
new RealOpcUaClientFactory(globalOptions, _loggerFactory),
|
||||
_loggerFactory.CreateLogger<OpcUaDataConnection>()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new protocol adapter factory. This is the extension point
|
||||
/// for adding new protocols without modifying existing code.
|
||||
/// </summary>
|
||||
/// <param name="protocolType">The case-insensitive protocol type string (e.g. "OpcUa").</param>
|
||||
/// <param name="factory">Factory delegate that creates an <see cref="IDataConnection"/> from connection details.</param>
|
||||
public void RegisterAdapter(string protocolType, Func<IDictionary<string, string>, IDataConnection> factory)
|
||||
{
|
||||
_factories[protocolType] = factory;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDataConnection Create(string protocolType, IDictionary<string, string> connectionDetails)
|
||||
{
|
||||
if (!_factories.TryGetValue(protocolType, out var factory))
|
||||
throw new ArgumentException($"Unknown protocol type: {protocolType}. Registered protocols: {string.Join(", ", _factories.Keys)}");
|
||||
|
||||
return factory(connectionDetails);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user