using System; using System.Text; using Avalonia; using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; using detect.gui.Drivers; using detect.gui.Services; using detect.gui.Services.Detect; using detect.gui.ViewModels; using detect.gui.Views; using ReactiveUI; using Splat; namespace detect.gui; public class App : Application { public override void Initialize() => AvaloniaXamlLoader.Load(this); public override void OnFrameworkInitializationCompleted() { var suspension = new AutoSuspendHelper(ApplicationLifetime!); RxApp.SuspensionHost.CreateNewAppState = () => new MainViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("app.state.json")); suspension.OnFrameworkInitializationCompleted(); Locator.CurrentMutable.RegisterConstant(RxApp.SuspensionHost.GetAppState()); Locator.CurrentMutable.Register(() => new LoginView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new HomeView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new DetectTaskView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new DeviceView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new LogView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new UserView(), typeof(IViewFor)); Locator.CurrentMutable.Register(() => new DetectUserService(), typeof(DetectUserService)); Locator.CurrentMutable.Register(() => new DetectDeviceService(), typeof(DetectDeviceService)); Locator.CurrentMutable.Register(() => new DetectTaskService(), typeof(DetectTaskService)); Locator.CurrentMutable.Register(() => new DetectLogService(), typeof(DetectLogService)); Locator.CurrentMutable.Register(() => new DetectAuthorityService(), typeof(DetectAuthorityService)); Locator.CurrentMutable.Register(() => new DeviceClientService(), typeof(DeviceClientService)); Locator.Current.GetService(); new MainView { DataContext = Locator.Current.GetService() }.Show(); base.OnFrameworkInitializationCompleted(); } }