Add a Scoped RepositoryCache that memoizes deserialized XML lists, keyed by absolute file path. Each XML file is loaded at most once per SignalR circuit; Save invalidates the corresponding entry so subsequent reads reload from disk. BaseRepository gains a LoadList<T>(fileName) helper; each of the seven repositories now defines Get*List() as a one-liner over that helper and takes RepositoryCache via the constructor. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
39 lines
1.9 KiB
C#
39 lines
1.9 KiB
C#
using Schaad.Accounting.Interfaces;
|
|
using Schaad.Accounting.Repositories;
|
|
using Schaad.Accounting.Services;
|
|
using Schaad.Finance.Api;
|
|
using Schaad.Finance.Services;
|
|
|
|
namespace Schaad.Accounting.UI
|
|
{
|
|
public static class Extensions
|
|
{
|
|
public static IServiceCollection AddAccounting(this IServiceCollection services)
|
|
{
|
|
// Singleton because MyHeader triggers a full page reload (forceLoad: true) after
|
|
// changing year/mandator; a Scoped instance would be recreated on the new circuit
|
|
// and lose the selection. TODO: persist selection to a cookie/query string so this
|
|
// can safely become Scoped (see IMPROVEMENT_PLAN.md).
|
|
services.AddSingleton<ISettingsService, SettingsService>();
|
|
|
|
services.AddScoped<RepositoryCache>();
|
|
services.AddScoped<IAccountRepository, AccountRepository>();
|
|
services.AddScoped<IBankTransactionRepository, BankTransactionRepository>();
|
|
services.AddScoped<IBookingRuleRepository, BookingRuleRepository>();
|
|
services.AddScoped<IBookingTextRepository, BookingTextRepository>();
|
|
services.AddScoped<ISplitPredefinitionRepository, SplitPredefinitionRepository>();
|
|
services.AddScoped<ISubclassRepository, SubclassRepository>();
|
|
services.AddScoped<ITransactionRepository, TransactionRepository>();
|
|
|
|
services.AddScoped<IChartService, ChartService>();
|
|
services.AddScoped<IViewService, ViewService>();
|
|
services.AddScoped<IFileService, FileService>();
|
|
services.AddScoped<IAccountStatementService, AccountStatementService>();
|
|
services.AddScoped<ICreditCardStatementService, CreditCardStatementService>();
|
|
services.AddSingleton<IFxService, DummyFxService>();
|
|
services.AddSingleton<IPdfParsingService, PdfParsingService>();
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|