|
|
@@ -1,14 +1,19 @@
|
|
|
using Avalonia;
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
-
|
|
|
+using Microsoft.Extensions.DependencyInjection;
|
|
|
using qmonlib.ui.ViewModels;
|
|
|
using qmonlib.ui.Views;
|
|
|
+using System;
|
|
|
+using System.IO.Abstractions;
|
|
|
+using Quadarax.Foundation.Core.Logging;
|
|
|
+using Quadarax.Foundation.Core.QMonitor;
|
|
|
|
|
|
namespace qmonlib.ui;
|
|
|
|
|
|
public partial class App : Application
|
|
|
{
|
|
|
+ private IServiceProvider _services;
|
|
|
public override void Initialize()
|
|
|
{
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
@@ -16,6 +21,11 @@ public partial class App : Application
|
|
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
|
{
|
|
|
+ ConfigureServiceProvider();
|
|
|
+
|
|
|
+ // assign list of available services to the application resources
|
|
|
+ this.Resources[typeof(IServiceProvider)] = _services;
|
|
|
+
|
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
{
|
|
|
desktop.MainWindow = new MainWindow
|
|
|
@@ -33,4 +43,21 @@ public partial class App : Application
|
|
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
|
}
|
|
|
+
|
|
|
+ private void ConfigureServiceProvider()
|
|
|
+ {
|
|
|
+ var services = ConfigureServices();
|
|
|
+ _services = services.BuildServiceProvider();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static IServiceCollection ConfigureServices()
|
|
|
+ {
|
|
|
+ var services = new ServiceCollection();
|
|
|
+ //TODO: Put service registrations here
|
|
|
+
|
|
|
+ services.AddSingleton<QMonReceiver>(new QMonReceiver(new FileSystem(),
|
|
|
+ QMonReceiverConfiguration.CreateDefault(), false, new ConsoleLogger()));
|
|
|
+
|
|
|
+ return services;
|
|
|
+ }
|
|
|
}
|