feat(commons): add correlation/execution/node/deployment/revisionhash types

This commit is contained in:
Joseph Doherty
2026-05-26 04:26:01 -04:00
parent c168c1c9c6
commit fee4a8c008
5 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
namespace ZB.MOM.WW.OtOpcUa.Commons.Types;
public readonly record struct CorrelationId(Guid Value)
{
public static CorrelationId NewId() => new(Guid.NewGuid());
public override string ToString() => Value.ToString("N");
public static CorrelationId Parse(string s) => new(Guid.ParseExact(s, "N"));
public static bool TryParse(string? s, out CorrelationId id)
{
if (Guid.TryParseExact(s, "N", out var g)) { id = new CorrelationId(g); return true; }
id = default; return false;
}
}

View File

@@ -0,0 +1,13 @@
namespace ZB.MOM.WW.OtOpcUa.Commons.Types;
public readonly record struct DeploymentId(Guid Value)
{
public static DeploymentId NewId() => new(Guid.NewGuid());
public override string ToString() => Value.ToString("N");
public static DeploymentId Parse(string s) => new(Guid.ParseExact(s, "N"));
public static bool TryParse(string? s, out DeploymentId id)
{
if (Guid.TryParseExact(s, "N", out var g)) { id = new DeploymentId(g); return true; }
id = default; return false;
}
}

View File

@@ -0,0 +1,13 @@
namespace ZB.MOM.WW.OtOpcUa.Commons.Types;
public readonly record struct ExecutionId(Guid Value)
{
public static ExecutionId NewId() => new(Guid.NewGuid());
public override string ToString() => Value.ToString("N");
public static ExecutionId Parse(string s) => new(Guid.ParseExact(s, "N"));
public static bool TryParse(string? s, out ExecutionId id)
{
if (Guid.TryParseExact(s, "N", out var g)) { id = new ExecutionId(g); return true; }
id = default; return false;
}
}

View File

@@ -0,0 +1,20 @@
namespace ZB.MOM.WW.OtOpcUa.Commons.Types;
/// <summary>
/// Logical cluster node identifier — typically the host name configured on a fused
/// <c>OtOpcUa.Host</c> instance. NOT to be confused with OPC UA <c>NodeId</c> from the
/// Opc.Ua.Core stack.
/// </summary>
public readonly record struct NodeId(string Value)
{
public override string ToString() => Value;
public static NodeId Parse(string s) =>
string.IsNullOrWhiteSpace(s)
? throw new ArgumentException("NodeId value cannot be empty.", nameof(s))
: new NodeId(s);
public static bool TryParse(string? s, out NodeId id)
{
if (!string.IsNullOrWhiteSpace(s)) { id = new NodeId(s); return true; }
id = default; return false;
}
}

View File

@@ -0,0 +1,19 @@
namespace ZB.MOM.WW.OtOpcUa.Commons.Types;
/// <summary>
/// SHA-256 hex digest identifying a config snapshot revision. Storage form is lowercase
/// 64-char hex (no <c>0x</c> prefix). Empty hash is invalid.
/// </summary>
public readonly record struct RevisionHash(string Value)
{
public override string ToString() => Value;
public static RevisionHash Parse(string s) =>
string.IsNullOrWhiteSpace(s)
? throw new ArgumentException("RevisionHash value cannot be empty.", nameof(s))
: new RevisionHash(s);
public static bool TryParse(string? s, out RevisionHash hash)
{
if (!string.IsNullOrWhiteSpace(s)) { hash = new RevisionHash(s); return true; }
hash = default; return false;
}
}