OperatorId.cs
1 namespace GUNRPG.Core.Operators; 2 3 /// <summary> 4 /// Strong-typed identifier for an Operator. 5 /// Provides type safety and clear intent when working with operator identities. 6 /// </summary> 7 public readonly struct OperatorId : IEquatable<OperatorId> 8 { 9 public Guid Value { get; } 10 11 /// <summary> 12 /// Returns true if this is an empty/default operator ID (Guid.Empty). 13 /// </summary> 14 public bool IsEmpty => Value == Guid.Empty; 15 16 public OperatorId(Guid value) 17 { 18 if (value == Guid.Empty) 19 throw new ArgumentException("OperatorId cannot be empty", nameof(value)); 20 21 Value = value; 22 } 23 24 public static OperatorId NewId() => new(Guid.NewGuid()); 25 26 public static OperatorId FromGuid(Guid value) => new(value); 27 28 public bool Equals(OperatorId other) => Value.Equals(other.Value); 29 30 public override bool Equals(object? obj) => obj is OperatorId other && Equals(other); 31 32 public override int GetHashCode() => Value.GetHashCode(); 33 34 public override string ToString() => Value.ToString(); 35 36 public static bool operator ==(OperatorId left, OperatorId right) => left.Equals(right); 37 38 public static bool operator !=(OperatorId left, OperatorId right) => !left.Equals(right); 39 }