26 lines
891 B
C#
26 lines
891 B
C#
namespace InnovEnergy.Lib.Units;
|
|
|
|
public readonly struct State
|
|
{
|
|
public IReadOnlyList<String> Values { get; }
|
|
|
|
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()){}
|
|
|
|
public State(Enum e) : this(e.ToString()){}
|
|
|
|
public static implicit operator State(Enum e) => new State(e);
|
|
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);
|
|
} |