DataSourceAdapter-Pattern + SiteExportService schlanker + Page-Services Scoped
- IDataSourceAdapter mit 3 Implementierungen (HANA, SAP_GATEWAY, MANUAL_EXCEL) und DataSourceAdapterResolver ersetzen das if/else auf ConnectionKind. - SiteExportService von 338 auf 187 Zeilen reduziert: Pipeline Resolve -> Fetch -> Transform -> Excel -> Central -> SharePoint. - Page-Services auf Scoped (per Blazor-Circuit); Orchestrator bleibt Singleton fuer geteilten Export-Status.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using TrafagSalesExporter.Models;
|
||||
|
||||
namespace TrafagSalesExporter.Services.DataSources;
|
||||
|
||||
public sealed class DataSourceAdapterResolver : IDataSourceAdapterResolver
|
||||
{
|
||||
private readonly Dictionary<string, IDataSourceAdapter> _adapters;
|
||||
|
||||
public DataSourceAdapterResolver(IEnumerable<IDataSourceAdapter> adapters)
|
||||
{
|
||||
_adapters = adapters.ToDictionary(
|
||||
a => a.ConnectionKind,
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public IDataSourceAdapter Resolve(string connectionKind)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionKind))
|
||||
connectionKind = SourceSystemConnectionKinds.Hana;
|
||||
|
||||
if (_adapters.TryGetValue(connectionKind, out var adapter))
|
||||
return adapter;
|
||||
|
||||
throw new InvalidOperationException(
|
||||
$"Kein DataSourceAdapter fuer ConnectionKind '{connectionKind}' registriert.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user