Files
Beam/Beam.Data/BeamDataContext.cs
qwsdcvghyu89 7ed05abdb8 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.
2025-09-22 01:51:46 +10:00

51 lines
2.0 KiB
C#

using aeqw89.DataKeys;
using aeqw89.PersistentData;
using Beam.Dynamic;
using Beam.Models;
namespace Beam.Data {
using BeamFile = Models.File;
public class BeamDataContext : BaseDataDictionary {
#region Tables
public Table<Template> Templates {
get => GetOrCreateTable<Template>(nameof(Templates));
set => Set(nameof(Templates), value);
}
public Table<DataBindings> Bindings {
get => GetOrCreateTable<DataBindings>(nameof(Bindings));
set => Set(nameof(Bindings), value);
}
public Table<WebResource> Resources {
get => GetOrCreateTable<WebResource>(nameof(Resources));
set => Set(nameof(Resources), value);
}
public Table<ResourceDictionary> ResourceDictionaries {
get => GetOrCreateTable<ResourceDictionary>(nameof(ResourceDictionaries));
set => Set(nameof(ResourceDictionaries), value);
}
public Table<ImmutableState> InitialStates {
get => GetOrCreateTable<ImmutableState>(nameof(InitialStates));
set => Set(nameof(InitialStates), value);
}
public Table<BeamFile> Files {
get => GetOrCreateTable<BeamFile>(nameof(Files));
set => Set(nameof(Files), value);
}
#endregion
#region Junctions
public Junction<WebResource, ResourceDictionary> WebResourceToResourceDictionaryJunction {
get => GetOrCreateJunction<WebResource, ResourceDictionary>(nameof(WebResourceToResourceDictionaryJunction));
set => Set(nameof(WebResourceToResourceDictionaryJunction), value);
}
#endregion
#region Computed
public Dictionary<DataKey<WebResource>, ResourceDictionary[]> ResourceDictionariesByNovel =>
Resources.Keys.ToDictionary(x => x,
x => WebResourceToResourceDictionaryJunction[x].Select(y => ResourceDictionaries[y]).ToArray());
#endregion
}
}