Files
TaskHybrid/salesbook.Maui/MauiProgram.cs
2025-06-30 15:46:11 +02:00

67 lines
2.5 KiB
C#

using CommunityToolkit.Maui;
using CommunityToolkit.Mvvm.Messaging;
using IntegryApiClient.MAUI;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Logging;
using MudBlazor.Services;
using MudExtensions.Services;
using salesbook.Maui.Core.Services;
using salesbook.Shared;
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Messages.Activity.Copy;
using salesbook.Shared.Core.Messages.Activity.New;
using salesbook.Shared.Core.Messages.Back;
using salesbook.Shared.Core.Services;
namespace salesbook.Maui
{
public static class MauiProgram
{
private const string AppToken = "f0484398-1f8b-42f5-ab79-5282c164e1d8";
public static MauiApp CreateMauiApp()
{
InteractiveRenderSettings.ConfigureBlazorHybridRenderModes();
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); })
.UseLoginAzienda(AppToken);
builder.Services.AddMauiBlazorWebView();
builder.Services.AddMudServices();
builder.Services.AddMudExtensions();
builder.Services.AddAutoMapper(typeof(MappingProfile));
builder.Services.AddAuthorizationCore();
builder.Services.AddScoped<AppAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(provider =>
provider.GetRequiredService<AppAuthenticationStateProvider>());
builder.Services.AddScoped<INetworkService, NetworkService>();
builder.Services.AddScoped<IIntegryApiService, IntegryApiService>();
builder.Services.AddScoped<ISyncDbService, SyncDbService>();
builder.Services.AddScoped<IManageDataService, ManageDataService>();
//Message
builder.Services.AddScoped<IMessenger, WeakReferenceMessenger>();
builder.Services.AddScoped<NewActivityService>();
builder.Services.AddScoped<BackNavigationService>();
builder.Services.AddScoped<CopyActivityService>();
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
builder.Logging.AddDebug();
#endif
builder.Services.AddSingleton<IFormFactor, FormFactor>();
builder.Services.AddSingleton<LocalDbService>();
return builder.Build();
}
}
}