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,53 @@
|
||||
using ZB.MOM.WW.ScadaBridge.TemplateEngine;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.ScriptAnalysis;
|
||||
|
||||
/// <summary>
|
||||
/// Indirection so ScriptAnalysisService can be unit-tested without standing
|
||||
/// up SharedScriptService and its EF Core repository chain.
|
||||
/// </summary>
|
||||
public interface ISharedScriptCatalog
|
||||
{
|
||||
/// <summary>Returns the parameter and return shapes for all registered shared scripts.</summary>
|
||||
Task<IReadOnlyList<ScriptShape>> GetShapesAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the source code and metadata for a named shared script, or
|
||||
/// null if no shared script with that name exists. Used by Test Run to
|
||||
/// compile and execute nested CallShared invocations.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the shared script to retrieve.</param>
|
||||
/// <param name="cancellationToken">Cancellation token for the async lookup.</param>
|
||||
Task<SharedScriptSource?> GetByNameAsync(string name, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public record SharedScriptSource(string Name, string Code, string? ParameterDefinitions, string? ReturnDefinition);
|
||||
|
||||
public class SharedScriptCatalog : ISharedScriptCatalog
|
||||
{
|
||||
private readonly SharedScriptService _service;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="SharedScriptCatalog"/> backed by the given service.
|
||||
/// </summary>
|
||||
/// <param name="service">Service providing access to shared script definitions.</param>
|
||||
public SharedScriptCatalog(SharedScriptService service) => _service = service;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyList<ScriptShape>> GetShapesAsync()
|
||||
{
|
||||
var scripts = await _service.GetAllSharedScriptsAsync();
|
||||
return scripts
|
||||
.Select(s => ScriptShapeParser.Parse(s.Name, s.ParameterDefinitions, s.ReturnDefinition))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SharedScriptSource?> GetByNameAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) return null;
|
||||
var scripts = await _service.GetAllSharedScriptsAsync(cancellationToken);
|
||||
var s = scripts.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal));
|
||||
return s == null ? null : new SharedScriptSource(s.Name, s.Code, s.ParameterDefinitions, s.ReturnDefinition);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user