From a3ccd2a537aa99bdf38fa4ba20a6842d38978e97 Mon Sep 17 00:00:00 2001 From: atef Date: Thu, 2 Mar 2023 15:14:22 +0100 Subject: [PATCH] Add more implicit conversions for State --- csharp/Lib/Units/State.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/csharp/Lib/Units/State.cs b/csharp/Lib/Units/State.cs index 3060186de..63b1c6d7c 100644 --- a/csharp/Lib/Units/State.cs +++ b/csharp/Lib/Units/State.cs @@ -15,12 +15,15 @@ public readonly struct State public State(params String[] values) : this((IReadOnlyList)values){} public State(params State[] states) : this((IReadOnlyList)states.SelectMany(s => s.Values).ToList()){} - public static implicit operator State(String s) => new State(s); - public static implicit operator State(Enum e) => new State(e.ToString()); - public static implicit operator State(Boolean s) => new State(s.ToString()); - public static implicit operator State(List s) => new State((IReadOnlyList)s); + public static implicit operator State(String s) => new(s); + public static implicit operator State(Enum e) => new(e.ToString()); + public static implicit operator State(Boolean s) => new(s.ToString()); + public static implicit operator State(List s) => new((IReadOnlyList)s); + public static implicit operator State(String[] s) => new((IReadOnlyList)s); + public static implicit operator State(List es) => new(es.Select(e => e.ToString()).ToArray()); + public static implicit operator State(Enum[] es) => new(es.Select(e => e.ToString()).ToArray()); - public static State operator |(State left, State right) => new State(left, right); + public static State operator |(State left, State right) => new(left, right); public override String ToString() => String.Join("; ", Values); } \ No newline at end of file