Phase 0 WP-0.2–0.9: Implement Commons (types, entities, interfaces, messages, protocol, tests)

- WP-0.2: Namespace/folder skeleton (26 directories)
- WP-0.3: Shared data types (6 enums, RetryPolicy, Result<T>)
- WP-0.4: 24 domain entity POCOs across 10 domain areas
- WP-0.5: 7 repository interfaces with full CRUD signatures
- WP-0.6: IAuditService cross-cutting interface
- WP-0.7: 26 message contract records across 8 concern areas
- WP-0.8: IDataConnection protocol abstraction with batch ops
- WP-0.9: 8 architectural constraint enforcement tests
All 40 tests pass, zero warnings.
This commit is contained in:
Joseph Doherty
2026-03-16 18:48:24 -04:00
parent fed5f5a82c
commit 22e1eba58a
78 changed files with 1530 additions and 16 deletions

View File

@@ -0,0 +1,7 @@
namespace ScadaLink.Commons.Types.Enums;
public enum AlarmState
{
Active,
Normal
}

View File

@@ -0,0 +1,8 @@
namespace ScadaLink.Commons.Types.Enums;
public enum AlarmTriggerType
{
ValueMatch,
RangeViolation,
RateOfChange
}

View File

@@ -0,0 +1,9 @@
namespace ScadaLink.Commons.Types.Enums;
public enum ConnectionHealth
{
Connected,
Disconnected,
Connecting,
Error
}

View File

@@ -0,0 +1,12 @@
namespace ScadaLink.Commons.Types.Enums;
public enum DataType
{
Boolean,
Int32,
Float,
Double,
String,
DateTime,
Binary
}

View File

@@ -0,0 +1,9 @@
namespace ScadaLink.Commons.Types.Enums;
public enum DeploymentStatus
{
Pending,
InProgress,
Success,
Failed
}

View File

@@ -0,0 +1,7 @@
namespace ScadaLink.Commons.Types.Enums;
public enum InstanceState
{
Enabled,
Disabled
}

View File

@@ -0,0 +1,40 @@
namespace ScadaLink.Commons.Types;
public sealed class Result<T>
{
private readonly T? _value;
private readonly string? _error;
private Result(T value)
{
_value = value;
_error = null;
IsSuccess = true;
}
private Result(string error)
{
_value = default;
_error = error;
IsSuccess = false;
}
public bool IsSuccess { get; }
public bool IsFailure => !IsSuccess;
public T Value => IsSuccess
? _value!
: throw new InvalidOperationException("Cannot access Value on a failed Result. Error: " + _error);
public string Error => IsFailure
? _error!
: throw new InvalidOperationException("Cannot access Error on a successful Result.");
public static Result<T> Success(T value) => new(value);
public static Result<T> Failure(string error) => new(error);
public TResult Match<TResult>(Func<T, TResult> onSuccess, Func<string, TResult> onFailure) =>
IsSuccess ? onSuccess(_value!) : onFailure(_error!);
}

View File

@@ -0,0 +1,3 @@
namespace ScadaLink.Commons.Types;
public record RetryPolicy(int MaxRetries, TimeSpan Delay);