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