- tweak: noUi time
This commit is contained in:
@@ -23,6 +23,8 @@ public partial class App : Application
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddAvaloniaServices();
|
||||
services.AddViews();
|
||||
services.AddServices();
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
11
Nebula.Launcher/AppNoUi.cs
Normal file
11
Nebula.Launcher/AppNoUi.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Nebula.Launcher.Services;
|
||||
|
||||
namespace Nebula.Launcher;
|
||||
|
||||
public class AppNoUi(RunnerService runnerService, AuthService authService)
|
||||
{
|
||||
public void Run(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Nebula.Launcher;
|
||||
|
||||
@@ -9,11 +10,34 @@ sealed class Program
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var uiMode = false;
|
||||
|
||||
if (uiMode)
|
||||
{
|
||||
BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
RunNoUI(args);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RunNoUI(string[] args)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddAvaloniaServices();
|
||||
services.AddServices();
|
||||
services.AddSingleton<AppNoUi>(); //Separated because no ui
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
serviceProvider.GetService<AppNoUi>()!.Run(args);
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
private static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.WithInterFont()
|
||||
|
||||
@@ -15,13 +15,7 @@ namespace Nebula.Launcher;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddAvaloniaServices();
|
||||
services.AddViews();
|
||||
}
|
||||
|
||||
private static void AddAvaloniaServices(this IServiceCollection services)
|
||||
public static void AddAvaloniaServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IDispatcher>(_ => Dispatcher.UIThread);
|
||||
services.AddSingleton(_ => Application.Current?.ApplicationLifetime ?? throw new InvalidOperationException("No application lifetime is set"));
|
||||
@@ -38,7 +32,7 @@ public static class ServiceCollectionExtensions
|
||||
services.AddSingleton(sp => sp.GetRequiredService<TopLevel>().StorageProvider);
|
||||
}
|
||||
|
||||
private static void AddViews(this IServiceCollection services)
|
||||
public static void AddViews(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<MainWindow>();
|
||||
|
||||
@@ -47,7 +41,11 @@ public static class ServiceCollectionExtensions
|
||||
services.AddSingleton(viewModel);
|
||||
services.AddTransient(view);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void AddServices(this IServiceCollection services)
|
||||
{
|
||||
foreach (var (type, inference) in GetServicesWithHelpAttribute(Assembly.GetExecutingAssembly()))
|
||||
{
|
||||
if (inference is null)
|
||||
|
||||
@@ -86,12 +86,10 @@ public class ConfigurationService
|
||||
var serializedData = JsonSerializer.Serialize(value);
|
||||
|
||||
using var stream = new MemoryStream();
|
||||
using (var writer = new StreamWriter(stream))
|
||||
{
|
||||
writer.Write(serializedData);
|
||||
writer.Flush();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
using var writer = new StreamWriter(stream);
|
||||
writer.Write(serializedData);
|
||||
writer.Flush();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
_fileService.ConfigurationApi.Save(GetFileName(conVar), stream);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
Background="#00000000"
|
||||
ItemsSource="{Binding AuthUrls}"
|
||||
Margin="5"
|
||||
SelectedItem="{Binding AuthItemSelect}">
|
||||
SelectedItem="{Binding AuthItemSelect}"
|
||||
SelectionMode="Toggle">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label>
|
||||
|
||||
Reference in New Issue
Block a user