From 97b2e40949dcc3030c27cb89c56c9ed31d1322a8 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 25 Nov 2025 23:38:06 +1000 Subject: [PATCH] refactor DI --- .../DependencyInjection.cs | 39 +++++++++++++++++++ src/SharpIDE.Godot/DiAutoload.cs | 32 ++------------- 2 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 src/SharpIDE.Application/DependencyInjection.cs diff --git a/src/SharpIDE.Application/DependencyInjection.cs b/src/SharpIDE.Application/DependencyInjection.cs new file mode 100644 index 0000000..7a73044 --- /dev/null +++ b/src/SharpIDE.Application/DependencyInjection.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.DependencyInjection; +using SharpIDE.Application.Features.Analysis; +using SharpIDE.Application.Features.Build; +using SharpIDE.Application.Features.Evaluation; +using SharpIDE.Application.Features.FilePersistence; +using SharpIDE.Application.Features.FileWatching; +using SharpIDE.Application.Features.NavigationHistory; +using SharpIDE.Application.Features.Nuget; +using SharpIDE.Application.Features.Run; +using SharpIDE.Application.Features.Search; +using SharpIDE.Application.Features.Testing; + +namespace SharpIDE.Application; + +public static class DependencyInjection +{ + public static IServiceCollection AddApplication(this IServiceCollection services) + { + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + return services; + } +} diff --git a/src/SharpIDE.Godot/DiAutoload.cs b/src/SharpIDE.Godot/DiAutoload.cs index c0ff9dd..3924259 100644 --- a/src/SharpIDE.Godot/DiAutoload.cs +++ b/src/SharpIDE.Godot/DiAutoload.cs @@ -3,16 +3,7 @@ using System.Reflection; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using SharpIDE.Application.Features.Analysis; -using SharpIDE.Application.Features.Build; -using SharpIDE.Application.Features.Evaluation; -using SharpIDE.Application.Features.FilePersistence; -using SharpIDE.Application.Features.FileWatching; -using SharpIDE.Application.Features.NavigationHistory; -using SharpIDE.Application.Features.Nuget; -using SharpIDE.Application.Features.Run; -using SharpIDE.Application.Features.Search; -using SharpIDE.Application.Features.Testing; +using SharpIDE.Application; using SharpIDE.Godot.Features.ActivityListener; namespace SharpIDE.Godot; @@ -29,25 +20,8 @@ public partial class DiAutoload : Node { GD.Print("[Injector] _EnterTree called"); var services = new ServiceCollection(); - // Register services here - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + + services.AddApplication(); services.AddScoped(); services.AddScoped();