InkForge/app/InkForge.Desktop/Microsoft/Extensions/DependencyInjection/InkForgeServiceCollection.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2024-03-17 22:27:01 +01:00
using Avalonia.Controls.Templates;
using Dock.Model.Core;
using InkForge.Data;
2024-03-17 22:27:01 +01:00
using InkForge.Desktop;
2024-02-16 02:23:58 +01:00
using InkForge.Desktop.Data;
using InkForge.Desktop.Data.Options;
using InkForge.Desktop.Managers;
using InkForge.Desktop.Models;
2024-03-17 22:27:01 +01:00
using InkForge.Desktop.ViewModels.Workspaces;
using InkForge.Desktop.ViewModels.Workspaces.Internal;
2024-02-09 01:23:38 +01:00
2024-02-16 02:23:58 +01:00
using Microsoft.EntityFrameworkCore;
2024-02-09 01:23:38 +01:00
namespace Microsoft.Extensions.DependencyInjection;
public static class InkForgeServiceCollections
{
public static IServiceCollection AddInkForge(this IServiceCollection services)
{
services.AddHttpClient();
2024-02-26 18:08:18 +01:00
// Singletons
// - Concrete
services.AddSingleton<DocumentManager>();
2024-03-17 22:27:01 +01:00
services.AddSingleton<InkForgeFactory>();
2024-02-26 18:08:18 +01:00
services.AddSingleton<WorkspaceManager>();
2024-03-17 22:27:01 +01:00
// - Service
services.AddSingleton<IDataTemplate, AppViewLocator>();
services.AddSingleton<IWorkspaceViewModelFactory, WorkspaceViewModelFactory>();
2024-02-16 02:23:58 +01:00
2024-02-26 18:08:18 +01:00
// Scoped
// - Concrete
services.AddScoped<LocalWorkspaceOptions>();
2024-04-05 12:31:34 +02:00
services.AddScoped<NoteStore>();
2024-02-09 01:23:38 +01:00
2024-02-26 18:08:18 +01:00
// - Service
services.AddScoped<IDbContextFactory<NoteDbContext>, NoteDbContextFactory>();
services.AddScoped<IWorkspaceContext, WorkspaceContext>();
// - Forwarders
services.AddScoped(s => s.GetRequiredService<IWorkspaceContext>().Workspace!);
2024-02-09 01:23:38 +01:00
return services;
}
}