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,6 +1,4 @@
|
||||
using Beam.Dynamic;
|
||||
|
||||
namespace Beam.Abstractions;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
public interface IDataBindings {
|
||||
IDataProvider<string>? Title { get; set; }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using HtmlAgilityPack;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Beam.Dynamic;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
public interface IDataProvider {
|
||||
public string GetString(HtmlDocument document)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Beam.Models;
|
||||
|
||||
namespace Beam.Abstractions;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
public interface ILinkBuilder {
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Beam.Models;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
public interface IReadOnlyState {
|
||||
public string[] GetState();
|
||||
IReadOnlyState Copy();
|
||||
public ReadOnlySpan<string> GetState();
|
||||
IState Copy();
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using Beam.Models;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
namespace Beam.Abstractions;
|
||||
public interface IState {
|
||||
|
||||
public interface IState : IReadOnlyState {
|
||||
string[] GetState();
|
||||
void SetState(string[] state);
|
||||
new IState Copy();
|
||||
IReadOnlyState AsReadOnly();
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using Beam.Models;
|
||||
|
||||
namespace Beam.Abstractions;
|
||||
namespace Beam.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Defines how a url template should should be updated, in what order, and by how much
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Net;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam {
|
||||
public class ApiCallBuilder(HttpClient client) {
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace Beam.Data {
|
||||
}
|
||||
|
||||
public string Build(IReadOnlyState state)
|
||||
=> Build(state.GetState().ToArray<object>());
|
||||
=> Build(state.GetState().ToArray().ToArray<object>());
|
||||
|
||||
#region Build
|
||||
/// <summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class AnchorCollectionDataProvider : IDataProvider<string[]> {
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class AnchorDataProvider : IDataProvider<string> {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using HtmlAgilityPack;
|
||||
using Beam.Abstractions;
|
||||
using HtmlAgilityPack;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class ContentsArrayDataProvider : ContentsDataProvider, IDataProvider<string[]> {
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class ContentsDataProvider : IDataProvider<string> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Runtime.InteropServices.Marshalling;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class DropDownDataProvider
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using HtmlAgilityPack;
|
||||
using System.Text;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class ListContentDataProvider : IDataProvider<string> {
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Beam.Abstractions;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class ParagraphedContentDataProvider : IDataProvider<string> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Beam.Abstractions;
|
||||
using Beam.Models;
|
||||
using Beam.Models;
|
||||
using HtmlAgilityPack;
|
||||
using Beam.Playwright;
|
||||
using Beam.Stealth;
|
||||
using Beam;
|
||||
using Beam.Abstractions;
|
||||
using Beam.Downloaders;
|
||||
|
||||
namespace Beam.Fluent {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -5,16 +5,19 @@ namespace Beam.Models {
|
||||
string[] state = state;
|
||||
|
||||
public string[] GetState() => state;
|
||||
|
||||
public void SetState(string[] state) => this.state = state;
|
||||
|
||||
public IReadOnlyState AsReadOnly() => new ImmutableState(this.state);
|
||||
|
||||
public State Copy()
|
||||
=> new((string[])state.Clone());
|
||||
|
||||
IReadOnlyState IReadOnlyState.Copy()
|
||||
=> Copy();
|
||||
IState IState.Copy()
|
||||
=> Copy();
|
||||
|
||||
public static implicit operator ImmutableState(State state) => new ImmutableState(state.GetState());
|
||||
|
||||
public string this[Index i] {
|
||||
get => state[i];
|
||||
set => state[i] = value;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Beam {
|
||||
}
|
||||
|
||||
Behaviour.Apply(State, 1);
|
||||
Current = Builder.Build(State);
|
||||
Current = Builder.Build(State.AsReadOnly());
|
||||
|
||||
return !string.IsNullOrWhiteSpace(Current) && (EndState is null || !State.GetState().SequenceEqual(EndState.GetState()));
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace Beam {
|
||||
public void Reset() {
|
||||
State = InitialState.Copy();
|
||||
Behaviour.Apply(State, -1);
|
||||
Current = Builder.Build(State);
|
||||
Current = Builder.Build(State.AsReadOnly());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user