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