diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 87c824236..7e16f47f8 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 87c824236324891001bd0d0f84698d430e3704b0 +Subproject commit 7e16f47f860ec4ca3316e5ed803ec7ea79c312a3 diff --git a/Aaru.Generators/PluginRegisterGenerator.cs b/Aaru.Generators/PluginRegisterGenerator.cs index 15e949ae0..c981a3f48 100644 --- a/Aaru.Generators/PluginRegisterGenerator.cs +++ b/Aaru.Generators/PluginRegisterGenerator.cs @@ -109,16 +109,14 @@ public class PluginRegisterGenerator : ISourceGenerator if(archives?.Count > 0) { - sb.AppendLine(" public List GetAllArchivePlugins() => new()"); + sb.AppendLine(" public void RegisterArchivePlugins(IServiceCollection services)"); sb.AppendLine(" {"); - foreach(string plugin in archives) - sb.AppendLine($" typeof({plugin}),"); - - sb.AppendLine(" };"); + sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else - sb.AppendLine(" public List GetAllArchivePlugins() => null;"); + sb.AppendLine(" public void RegisterArchivePlugins(IServiceCollection services) {}"); sb.AppendLine(); diff --git a/Aaru/Commands/Formats.cs b/Aaru/Commands/Formats.cs index 776e262c2..807170794 100644 --- a/Aaru/Commands/Formats.cs +++ b/Aaru/Commands/Formats.cs @@ -100,12 +100,12 @@ sealed class FormatsCommand : Command table.AddColumn(UI.Title_Filter); - foreach(KeyValuePair kvp in PluginRegister.Singleton.Filters) + foreach(IFilter filter in PluginRegister.Singleton.Filters.Values) { if(verbose) - table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name)); + table.AddRow(filter.Id.ToString(), Markup.Escape(filter.Name)); else - table.AddRow(Markup.Escape(kvp.Value.Name)); + table.AddRow(Markup.Escape(filter.Name)); } AnsiConsole.Write(table); @@ -256,9 +256,9 @@ sealed class FormatsCommand : Command table.AddColumn("Archive format"); - foreach(KeyValuePair kvp in plugins.Archives) + foreach(IArchive archive in plugins.Archives.Values) { - if(Activator.CreateInstance(kvp.Value) is not IArchive archive) + if(archive is null) continue; if(verbose)