[Plugin system] Move filesystems to dependency injection.

This commit is contained in:
2023-10-05 16:39:06 +01:00
parent e19cdd942a
commit bc7e02b24c
9 changed files with 46 additions and 55 deletions

View File

@@ -135,16 +135,14 @@ public class PluginRegisterGenerator : ISourceGenerator
if(fileSystems?.Count > 0)
{
sb.AppendLine(" public List<Type> GetAllFilesystemPlugins() => new()");
sb.AppendLine(" public void RegisterFilesystemPlugins(IServiceCollection services)");
sb.AppendLine(" {");
foreach(string plugin in fileSystems)
sb.AppendLine($" typeof({plugin}),");
sb.AppendLine(" };");
sb.AppendLine($" services.AddTransient<IFilesystem, {plugin}>();");
sb.AppendLine(" }");
}
else
sb.AppendLine(" public List<Type> GetAllFilesystemPlugins() => null;");
sb.AppendLine(" public void RegisterFilesystemPlugins(IServiceCollection services) {}");
sb.AppendLine();