SQLLite vol 1.
This commit is contained in:
@@ -3,6 +3,8 @@ using Microsoft.Extensions.Logging;
|
||||
using WorkFlowCheck.MAUI.Services;
|
||||
using Microsoft.Extensions.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using CommunityToolkit.Maui;
|
||||
using WorkFlowCheck.MAUI.DataLayer;
|
||||
|
||||
namespace WorkFlowCheck.MAUI
|
||||
{
|
||||
@@ -11,12 +13,8 @@ namespace WorkFlowCheck.MAUI
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
|
||||
|
||||
// appsettings.json beállítása
|
||||
|
||||
string jsonFilePath = Path.Combine(FileSystem.AppDataDirectory, "appsettings.json");
|
||||
|
||||
// Másold a fájlt a Raw erőforrásokból az AppDataDirectory-ba, ha még nincs ott
|
||||
if (!File.Exists(jsonFilePath))
|
||||
{
|
||||
@@ -25,43 +23,37 @@ namespace WorkFlowCheck.MAUI
|
||||
File.WriteAllText(jsonFilePath, reader.ReadToEnd());
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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.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.AddDbContext<AppDbContext>();
|
||||
|
||||
builder.Services.AddSingleton<IConfiguration>(configuration);
|
||||
builder.Services.AddSingleton<IUserService, UserService>();
|
||||
builder.Services.AddSingleton<ISyncService, SyncService>();
|
||||
|
||||
builder.Services.AddTransient<IUserService, UserService>();
|
||||
builder.Services.AddTransient<MainPage>();
|
||||
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||
});
|
||||
|
||||
|
||||
builder.UseMauiApp<App>().ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||
}).UseMauiCommunityToolkit();
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
// HttpClient regisztrálása az alap API-címmel
|
||||
|
||||
|
||||
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