Na, majd otthon ...

This commit is contained in:
Iván Szabó
2025-01-06 12:49:34 +01:00
parent a80870b5c3
commit 92801fefb9
11 changed files with 106 additions and 18 deletions
+27 -2
View File
@@ -1,4 +1,8 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using WorkFlowCheck.MAUI.Services;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.DependencyInjection;
namespace WorkFlowCheck.MAUI
{
@@ -7,6 +11,19 @@ namespace WorkFlowCheck.MAUI
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
var configuration = new ConfigurationBuilder()
.SetBasePath(FileSystem.AppDataDirectory) // A konfigurációs fájl betöltése az alkalmazás adat könyvtárából
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
builder.Services.AddSingleton<IConfiguration>(configuration);
builder.Services.AddHttpClient<UserService>(client =>
{
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
client.BaseAddress = new Uri(apiUrl);
});
builder.Services.AddSingleton<IUserService, UserService>();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
@@ -18,8 +35,16 @@ namespace WorkFlowCheck.MAUI
#if DEBUG
builder.Logging.AddDebug();
#endif
// HttpClient regisztrálása az alap API-címmel
return builder.Build();
var app = builder.Build();
// Szolgáltató tárolása globálisan
ServiceProvider = app.Services;
return app;
}
public static IServiceProvider ServiceProvider { get; private set; }
}
}