Files
EnvelopeGenerator/EnvelopeGenerator.ReceiverUI/Program.cs
TekH affdc44f91 Refactor startup and add report storage services
- Added `EnvelopeGen` as a trusted class for deserialization.
- Registered `InMemoryReportStorageWebExtension` as a singleton.
- Registered `ReportStorageWebExtension` as a singleton using a factory.
- Added `IReportProviderAsync` as a scoped service with `CustomReportProvider`.
- Registered `InMemoryReportStorageWebExtension` globally.
- Refactored app startup to load fonts asynchronously before running:
  - Introduced `FontLoader.LoadFonts` to load "opensans.ttf".
  - Replaced `await builder.Build().RunAsync()` with a `host` variable.
2026-05-27 15:07:27 +02:00

33 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.AspNetCore.Components.Web;
using EnvelopeGenerator.ReceiverUI;
using DevExpress.DataAccess.Web;
using EnvelopeGenerator.ReceiverUI.Services;
using DevExpress.XtraReports.Services;
using DevExpress.Blazor.Reporting;
using DevExpress.XtraReports.Web.Extensions;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddDevExpressWebAssemblyBlazorReportViewer();
builder.Services.AddDevExpressBlazorReportingWebAssembly(configure => {
configure.UseDevelopmentMode();
});
builder.Services.AddScoped<IDataSourceWizardJsonConnectionStorage, CustomDataSourceWizardJsonDataConnectionStorage>();
builder.Services.AddScoped<IJsonDataConnectionProviderFactory, CustomJsonDataConnectionProviderFactory>();
builder.Services.AddScoped<IObjectDataSourceWizardTypeProvider, ObjectDataSourceWizardCustomTypeProvider>();
DevExpress.Utils.DeserializationSettings.RegisterTrustedClass(typeof(EnvelopeGenerator.ReceiverUI.Data.DataItemList));
DevExpress.Utils.DeserializationSettings.RegisterTrustedClass(typeof(EnvelopeGenerator.ReceiverUI.PredefinedReports.Report));
builder.Services.AddSingleton<InMemoryReportStorageWebExtension>();
builder.Services.AddSingleton<ReportStorageWebExtension>(sp => sp.GetRequiredService<InMemoryReportStorageWebExtension>());
builder.Services.AddScoped<IReportProviderAsync, CustomReportProvider>();
ReportStorageWebExtension.RegisterExtensionGlobal(new InMemoryReportStorageWebExtension());
var host = builder.Build();
await FontLoader.LoadFonts(host.Services.GetRequiredService<HttpClient>(), new List<string> { "opensans.ttf" });
await host.RunAsync();