namespace Brutal.Localization; /// /// Strongly typed id for a LString created from a string or ReadOnlySpan{char}. /// LStringId objects are case-sensitive. /// The strings or ReadOnlySpans passed to the constructor cannot be null or empty. /// public readonly record struct LStringId { /// /// Helper to create a LStringId from a string. /// /// The case-sensitive string version of the id. /// The created LStringId. /// Thrown if id is null or empty. public static LStringId From(string id) { return new LStringId(id); } /// /// Create a LStringId from a ReadOnlySpan. /// /// NOTE: LStringId objects are case-insensitive. /// The ReadOnlySpan of chars of the LStringId to create. /// Thrown if the ReadOnlySpan is empty. public LStringId(ReadOnlySpan id) { if (id.IsEmpty) throw new ArgumentException($"Invalid LStringId '{id}'", nameof(id)); _value = id.ToString(); } /// /// Create a LStringId from a string. /// /// The case-sensitive string to use for the LStringId. /// Thrown if id is null or empty. public LStringId(string id) { if (string.IsNullOrEmpty(id)) throw new ArgumentException($"Invalid LStringId '{id}'"); _value = id; } /// /// The string value of the LStringId. /// public override string ToString() => _value; private readonly string _value; }