refactor DI

This commit is contained in:
Matt Parker
2025-11-25 23:38:06 +10:00
parent 6196a4f9e3
commit 97b2e40949
2 changed files with 42 additions and 29 deletions

View File

@@ -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<BuildService>();
services.AddScoped<RunService>();
services.AddScoped<SearchService>();
services.AddScoped<IdeFileExternalChangeHandler>();
services.AddScoped<IdeCodeActionService>();
services.AddScoped<IdeRenameService>();
services.AddScoped<IdeApplyCompletionService>();
services.AddScoped<FileChangedService>();
services.AddScoped<DotnetUserSecretsService>();
services.AddScoped<NugetClientService>();
services.AddScoped<TestRunnerService>();
services.AddScoped<NugetPackageIconCacheService>();
services.AddScoped<IdeFileWatcher>();
services.AddScoped<IdeNavigationHistoryService>();
services.AddScoped<IdeOpenTabsFileManager>();
services.AddScoped<RoslynAnalysis>();
services.AddScoped<IdeFileOperationsService>();
services.AddScoped<SharpIdeSolutionModificationService>();
return services;
}
}

View File

@@ -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<BuildService>();
services.AddScoped<RunService>();
services.AddScoped<SearchService>();
services.AddScoped<IdeFileExternalChangeHandler>();
services.AddScoped<IdeCodeActionService>();
services.AddScoped<IdeRenameService>();
services.AddScoped<IdeApplyCompletionService>();
services.AddScoped<FileChangedService>();
services.AddScoped<DotnetUserSecretsService>();
services.AddScoped<NugetClientService>();
services.AddScoped<TestRunnerService>();
services.AddScoped<NugetPackageIconCacheService>();
services.AddScoped<IdeFileWatcher>();
services.AddScoped<IdeNavigationHistoryService>();
services.AddScoped<IdeOpenTabsFileManager>();
services.AddScoped<RoslynAnalysis>();
services.AddScoped<IdeFileOperationsService>();
services.AddScoped<SharpIdeSolutionModificationService>();
services.AddApplication();
services.AddScoped<SharpIdeSolutionAccessor>();
services.AddScoped<ActivityMonitor>();