refactor(configmanager): rename UI project and split test projects
Rename ConfigManager to ConfigManager.Ui to match the Core/CLI/UI project structure, and split the monolithic test project into Core.Tests, Cli.Tests, and Ui.Tests to align with the source project organization.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using JdeScoping.ConfigManager.Core.DependencyInjection;
|
||||
using JdeScoping.ConfigManager.Ui.Services;
|
||||
using JdeScoping.ConfigManager.Ui.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Ui;
|
||||
|
||||
public partial class App : Avalonia.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the dependency injection service provider for the application.
|
||||
/// </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 Views.MainWindow
|
||||
{
|
||||
DataContext = Services.GetRequiredService<MainWindowViewModel>()
|
||||
};
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
|
||||
private void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Logging
|
||||
services.AddLogging(builder => builder
|
||||
.AddConsole()
|
||||
.SetMinimumLevel(LogLevel.Debug));
|
||||
|
||||
// Add all ConfigManager.Core services
|
||||
services.AddConfigManagerCore();
|
||||
|
||||
// Platform Services (Avalonia-specific)
|
||||
services.AddSingleton<IDialogService>(sp =>
|
||||
new AvaloniaDialogService(GetMainWindow));
|
||||
services.AddSingleton<IClipboardService>(sp =>
|
||||
new AvaloniaClipboardService(GetClipboard));
|
||||
|
||||
// ViewModels
|
||||
services.AddTransient<MainWindowViewModel>();
|
||||
}
|
||||
|
||||
private Window? GetMainWindow()
|
||||
{
|
||||
return (ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
|
||||
}
|
||||
|
||||
private IClipboard? GetClipboard()
|
||||
{
|
||||
return GetMainWindow()?.Clipboard;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user