Na, majd otthon ...
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user