1e21e33ade
Move SecureStoreManager project and tests to Deprecated folder and remove from solution. SecureStore functionality is now integrated into ConfigManager.
75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
using Avalonia.Markup.Xaml;
|
|
using JdeScoping.SecureStoreManager.Application;
|
|
using JdeScoping.SecureStoreManager.Services;
|
|
using JdeScoping.SecureStoreManager.ViewModels;
|
|
using JdeScoping.SecureStoreManager.Views;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace JdeScoping.SecureStoreManager;
|
|
|
|
public partial class App : Avalonia.Application
|
|
{
|
|
/// <summary>
|
|
/// Gets the service provider instance for dependency injection.
|
|
/// </summary>
|
|
public static IServiceProvider Services { get; private set; } = null!;
|
|
|
|
/// <inheritdoc />
|
|
public override void Initialize()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnFrameworkInitializationCompleted()
|
|
{
|
|
var services = new ServiceCollection();
|
|
ConfigureServices(services);
|
|
Services = services.BuildServiceProvider();
|
|
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
{
|
|
desktop.MainWindow = new MainWindow
|
|
{
|
|
DataContext = Services.GetRequiredService<MainWindowViewModel>()
|
|
};
|
|
}
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
}
|
|
|
|
private void ConfigureServices(IServiceCollection services)
|
|
{
|
|
// Logging
|
|
services.AddLogging(builder => builder
|
|
.AddConsole()
|
|
.SetMinimumLevel(LogLevel.Debug));
|
|
|
|
// Services
|
|
services.AddSingleton<ISecureStoreManager, Services.SecureStoreManager>();
|
|
|
|
// Platform Services (factory pattern for window access)
|
|
services.AddSingleton<IDialogService>(sp =>
|
|
new AvaloniaDialogService(GetMainWindow));
|
|
|
|
services.AddSingleton<IClipboardService>(sp =>
|
|
new AvaloniaClipboardService(() => GetMainWindow()?.Clipboard));
|
|
|
|
// Use Cases
|
|
services.AddTransient<StoreUseCases>();
|
|
services.AddTransient<SecretUseCases>();
|
|
|
|
// ViewModels
|
|
services.AddTransient<MainWindowViewModel>();
|
|
}
|
|
|
|
private Window? GetMainWindow()
|
|
{
|
|
return (ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
|
|
}
|
|
}
|