Overall; fixed design of IState.cs and IReadOnlyState.cs, and fixed namespaces in Beam.Abstractions to remove all references of Beam.Abstract.
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Models {
|
||||
public readonly struct ImmutableState {
|
||||
readonly string[] state;
|
||||
public readonly struct ImmutableState : IReadOnlyState {
|
||||
private readonly string[] state;
|
||||
|
||||
[JsonConstructor]
|
||||
public ImmutableState(string[] state) {
|
||||
this.state = state ?? [];
|
||||
public ImmutableState(params IEnumerable<string> state) {
|
||||
this.state = state.ToArray();
|
||||
}
|
||||
|
||||
public string[] State => state ?? [];
|
||||
|
||||
public readonly Span<string> AsSpan() => state ?? [];
|
||||
|
||||
public ReadOnlySpan<string> GetState() => this.state;
|
||||
|
||||
public readonly State Copy()
|
||||
=> new((string[])(state ?? []).Clone());
|
||||
|
||||
public readonly string this[Index i] {
|
||||
get => state[i];
|
||||
}
|
||||
|
||||
IState IReadOnlyState.Copy()
|
||||
=> Copy();
|
||||
public readonly string this[Index i] => state[i];
|
||||
public static implicit operator State(ImmutableState state)
|
||||
=> state.Copy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user