Batch Update

This commit is contained in:
Jöran Malek 2024-03-17 22:27:01 +01:00
parent 693d12b61c
commit 4c2b5cca93
32 changed files with 483 additions and 332 deletions

View file

@ -1,17 +1,18 @@
using Avalonia.Controls.Templates;
using Dock.Model.Core;
using InkForge.Data;
using InkForge.Desktop;
using InkForge.Desktop.Data;
using InkForge.Desktop.Data.Options;
using InkForge.Desktop.Dock;
using InkForge.Desktop.Managers;
using InkForge.Desktop.Models;
using InkForge.Desktop.ViewModels;
using InkForge.Desktop.ViewModels.Workspaces;
using InkForge.Desktop.ViewModels.Workspaces.Internal;
using Microsoft.EntityFrameworkCore;
using ReactiveUI;
using Splat;
namespace Microsoft.Extensions.DependencyInjection;
public static class InkForgeServiceCollections
@ -23,9 +24,12 @@ public static class InkForgeServiceCollections
// Singletons
// - Concrete
services.AddSingleton<DocumentManager>();
services.AddSingleton<WorkspaceFactory>();
services.AddSingleton<InkForgeFactory>();
services.AddSingleton<WorkspaceManager>();
services.AddSingleton<WorkspacesViewModel>();
// - Service
services.AddSingleton<IDataTemplate, AppViewLocator>();
services.AddSingleton<IWorkspaceViewModelFactory, WorkspaceViewModelFactory>();
// Scoped
// - Concrete
@ -38,8 +42,6 @@ public static class InkForgeServiceCollections
// - Forwarders
services.AddScoped(s => s.GetRequiredService<IWorkspaceContext>().Workspace!);
Locator.CurrentMutable.RegisterViewsForViewModels(typeof(InkForgeServiceCollections).Assembly);
return services;
}
}

View file

@ -1,37 +0,0 @@
namespace Microsoft.Extensions.DependencyInjection
{
public static class TypeFactory
{
public static T Create<T>(IServiceProvider serviceProvider)
{
return TypeFactory<EmptyArguments, T>.Create(serviceProvider, default);
}
}
public static class TypeFactory<TArguments, T>
where TArguments : IFactoryArguments<TArguments>
{
private static ObjectFactory<T>? s_objectFactory;
public static T Create(IServiceProvider serviceProvider, in TArguments factory)
{
s_objectFactory ??= ActivatorUtilities.CreateFactory<T>(TArguments.Types);
return s_objectFactory(serviceProvider, (object[])factory);
}
}
public readonly struct EmptyArguments : IFactoryArguments<EmptyArguments>
{
public static Type[] Types => [];
public static implicit operator object[](in EmptyArguments _) => [];
}
public interface IFactoryArguments<T>
where T : IFactoryArguments<T>
{
abstract static Type[] Types { get; }
abstract static implicit operator object[](in T self);
}
}