refactor: modularize Beam into new projects and interfaces

- Introduced modularity by splitting Beam into new projects: Beam.Abstractions, Beam.Models, and Beam.Downloaders.
- Refactored existing classes into appropriate namespaces and projects.
- Replaced specific implementations with abstractions (e.g., SourceLinkBuilder to LinkBuilder, State to IState, etc.).
- Updated interfaces: added ITemplate, IArticleData, IDownloadReport, and others for improved extensibility.
- Removed deprecated classes like SourceLinkBuilder and StateChangerFactory.
- Enhanced link handling in downloaders by refactoring to use `string` over `SourceLink`.
- Consolidated shared logic under Beam.Abstractions.
This commit is contained in:
qwsdcvghyu89
2025-09-22 01:51:46 +10:00
parent a7d148a96f
commit 7ed05abdb8
128 changed files with 2058 additions and 1804 deletions
@@ -0,0 +1,41 @@
using System.Text.Json;
using Beam.Abstractions;
namespace Beam.Models {
public record class ArticleData : IArticleData {
public string? Name { get; set; }
public string[] Authors { get; set; } = [];
public string? Language { get; set; }
public string[] Categories { get; set; } = [];
public string? Version { get; set; }
public string? Description { get; set; }
public string AsJson(JsonSerializerOptions? options = null) {
return JsonSerializer.Serialize(this, options);
}
public virtual bool Equals(ArticleData? other) {
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Authors.Equals(other.Authors) && Language == other.Language && Categories.Equals(other.Categories) && Version == other.Version && Description == other.Description;
}
public virtual bool Equals(IArticleData? other) {
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Authors.Equals(other.Authors) && Language == other.Language && Categories.Equals(other.Categories) && Version == other.Version && Description == other.Description;
}
public override int GetHashCode() {
unchecked {
var hashCode = (Name != null ? Name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Authors.GetHashCode();
hashCode = (hashCode * 397) ^ (Language != null ? Language.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Categories.GetHashCode();
hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
return hashCode;
}
}
}
}