implement ToString for State

This commit is contained in:
ig 2023-03-01 08:25:23 +01:00
parent f6f4326afa
commit 08c747f2ea
2 changed files with 14 additions and 12 deletions

View File

@ -7,13 +7,7 @@ public readonly struct Percent
public static String Unit => "%";
public static String Symbol => "%"; // ??
public Percent(Decimal value)
{
if (value < 0)
throw new ArgumentException(nameof(Frequency) + " cannot be negative", nameof(value));
Value = value;
}
public Percent(Decimal value) => Value = value;
// not generated

View File

@ -4,7 +4,13 @@ public readonly struct State
{
public IReadOnlyList<String> Values { get; }
public State(IReadOnlyList<String> values) => Values = values;
public State(IReadOnlyList<String> values)
{
if (values.Any(v => v.Contains(";")))
throw new ArgumentException("State values cannot contain the character ;", nameof(values));
Values = values;
}
public State(params String[] values) : this((IReadOnlyList<String>)values){}
public State(params State[] states) : this(states.SelectMany(s => s.Values).ToList()){}
@ -15,4 +21,6 @@ public readonly struct State
public static implicit operator State(String s) => new State(s);
public static State operator |(State left, State right) => new State(left, right);
public override String ToString() => String.Join("; ", Values);
}