Files
BQP/srcs/RobotNet10/RobotApp/RobotNet10.RobotApp.Client/Program.cs
2026-07-13 09:25:40 +07:00

78 lines
3.2 KiB
C#

using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor;
using MudBlazor.Services;
using RobotNet10.CustomConfigurationEditor.Services.API;
using RobotNet10.CustomConfigurationEditor.Services.State;
using RobotNet10.MapEditor.Services.API;
using RobotNet10.MapEditor.Services.State;
using RobotNet10.RobotApp.Client;
using RobotNet10.RobotApp.Client.Clients;
using RobotNet10.RobotApp.Client.Services;
using RobotNet10.ScriptEditor;
using RobotNet10.NavigationTuneUI.Clients;
using RobotNet10.NavigationTuneUI.Services;
using System.Globalization;
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Logging.AddFilter("System.Net.Http.HttpClient", LogLevel.Warning);
builder.Services.AddAuthorizationCore();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddAuthenticationStateDeserialization();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress), });
builder.Services.AddMudServices(config =>
{
config.SnackbarConfiguration.VisibleStateDuration = 2000;
config.SnackbarConfiguration.HideTransitionDuration = 500;
config.SnackbarConfiguration.ShowTransitionDuration = 500;
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft;
});
builder.Services.AddNavigationMenu();
builder.Services.AddScriptEditor<ScriptEngineResource>();
// MapEditor Services
builder.Services.AddScoped<MapManagerApiService>();
builder.Services.AddScoped<LayoutManagerState>();
builder.Services.AddScoped<LayoutEditorState>();
builder.Services.AddScoped<VehicleTypeManagerState>();
builder.Services.AddScoped<VehicleTypeEditState>();
builder.Services.AddScoped<StationManagerState>();
// Device Hub Clients
builder.Services.AddScoped<DeviceHubClient>();
builder.Services.AddScoped<OdometryHubClient>();
builder.Services.AddScoped<BatteryHubClient>();
builder.Services.AddScoped<InertialMeasurementUnitHubClient>();
builder.Services.AddScoped<LidarHubClient>();
builder.Services.AddScoped<ModbusTcpHubClient>();
builder.Services.AddScoped<RfHandleHubClient>();
builder.Services.AddScoped<CameraQrHubClient>();
builder.Services.AddScoped<CiA402ServoHubClient>();
builder.Services.AddScoped<MotionHubClient>();
builder.Services.AddScoped<SLAMClient>();
builder.Services.AddScoped<PlcControllerHubClient>();
builder.Services.AddScoped<MarkerDetectorHubClient>();
builder.Services.AddScoped<NavigationMonitorHubClient>();
// Navigation Tuning Services
builder.Services.AddScoped<TuningHubClient>();
builder.Services.AddScoped<TuningApiService>();
// Config Manager Services
builder.Services.AddScoped<ConfigApiService>();
builder.Services.AddScoped<ConfigManagerState>(sp =>
{
var configApi = sp.GetRequiredService<ConfigApiService>();
var authStateProvider = sp.GetService<AuthenticationStateProvider>();
return new ConfigManagerState(configApi, authStateProvider, "Distributor");
});
// DockStation Config Services
builder.Services.AddScoped<DockStationApiService>();
builder.Services.AddScoped<DockStationConfigState>();
await builder.Build().RunAsync();