mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Plugin system] Move archives to dependency injection.
This commit is contained in:
Submodule Aaru.CommonTypes updated: 87c8242363...7e16f47f86
@@ -109,16 +109,14 @@ public class PluginRegisterGenerator : ISourceGenerator
|
|||||||
|
|
||||||
if(archives?.Count > 0)
|
if(archives?.Count > 0)
|
||||||
{
|
{
|
||||||
sb.AppendLine(" public List<Type> GetAllArchivePlugins() => new()");
|
sb.AppendLine(" public void RegisterArchivePlugins(IServiceCollection services)");
|
||||||
sb.AppendLine(" {");
|
sb.AppendLine(" {");
|
||||||
|
|
||||||
foreach(string plugin in archives)
|
foreach(string plugin in archives)
|
||||||
sb.AppendLine($" typeof({plugin}),");
|
sb.AppendLine($" services.AddTransient<IArchive, {plugin}>();");
|
||||||
|
sb.AppendLine(" }");
|
||||||
sb.AppendLine(" };");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sb.AppendLine(" public List<Type> GetAllArchivePlugins() => null;");
|
sb.AppendLine(" public void RegisterArchivePlugins(IServiceCollection services) {}");
|
||||||
|
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
|
|||||||
@@ -100,12 +100,12 @@ sealed class FormatsCommand : Command
|
|||||||
|
|
||||||
table.AddColumn(UI.Title_Filter);
|
table.AddColumn(UI.Title_Filter);
|
||||||
|
|
||||||
foreach(KeyValuePair<string, IFilter> kvp in PluginRegister.Singleton.Filters)
|
foreach(IFilter filter in PluginRegister.Singleton.Filters.Values)
|
||||||
{
|
{
|
||||||
if(verbose)
|
if(verbose)
|
||||||
table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name));
|
table.AddRow(filter.Id.ToString(), Markup.Escape(filter.Name));
|
||||||
else
|
else
|
||||||
table.AddRow(Markup.Escape(kvp.Value.Name));
|
table.AddRow(Markup.Escape(filter.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiConsole.Write(table);
|
AnsiConsole.Write(table);
|
||||||
@@ -256,9 +256,9 @@ sealed class FormatsCommand : Command
|
|||||||
|
|
||||||
table.AddColumn("Archive format");
|
table.AddColumn("Archive format");
|
||||||
|
|
||||||
foreach(KeyValuePair<string, Type> 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;
|
continue;
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
|
|||||||
Reference in New Issue
Block a user