diff --git a/Aaru.Archives/Aaru.Archives.csproj b/Aaru.Archives/Aaru.Archives.csproj
index 5d40f76ea..4acd1c702 100644
--- a/Aaru.Archives/Aaru.Archives.csproj
+++ b/Aaru.Archives/Aaru.Archives.csproj
@@ -53,6 +53,7 @@
+
all
diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes
index 846a1792f..50e0b8071 160000
--- a/Aaru.CommonTypes
+++ b/Aaru.CommonTypes
@@ -1 +1 @@
-Subproject commit 846a1792f0fb9906305197e97a525f4d4b24e283
+Subproject commit 50e0b8071fb6898faae6ada7ee2a7938b7b62db5
diff --git a/Aaru.Core/Aaru.Core.csproj b/Aaru.Core/Aaru.Core.csproj
index a380f718a..c111eeba8 100644
--- a/Aaru.Core/Aaru.Core.csproj
+++ b/Aaru.Core/Aaru.Core.csproj
@@ -74,6 +74,7 @@
+
diff --git a/Aaru.Core/PluginBase.cs b/Aaru.Core/PluginBase.cs
index eaccd4915..86d7a0d0f 100644
--- a/Aaru.Core/PluginBase.cs
+++ b/Aaru.Core/PluginBase.cs
@@ -32,13 +32,16 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
-using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces;
+using Aaru.DiscImages;
+using Microsoft.Extensions.DependencyInjection;
namespace Aaru.Core;
/// Plugin base operations
+[SuppressMessage("ReSharper", "UnusedMember.Global")]
public sealed class PluginBase
{
static PluginBase _instance;
@@ -63,6 +66,8 @@ public sealed class PluginBase
public readonly SortedDictionary WritableFloppyImages;
/// List of writable media image plugins
public readonly SortedDictionary WritableImages;
+ IServiceProvider _serviceProvider;
+ IServiceCollection _services;
PluginBase()
{
@@ -78,6 +83,19 @@ public sealed class PluginBase
ByteAddressableImages = new SortedDictionary();
}
+ /// List of all checksums formats
+ public SortedDictionary Checksums
+ {
+ get
+ {
+ SortedDictionary checksums = new();
+ foreach(IChecksum plugin in _serviceProvider.GetServices())
+ checksums.Add(plugin.Name.ToLower(), plugin);
+
+ return checksums;
+ }
+ }
+
/// Gets a singleton with all the known plugins
public static PluginBase Singleton
{
@@ -86,22 +104,26 @@ public sealed class PluginBase
if(_instance != null)
return _instance;
- _instance = new PluginBase();
+ _instance = new PluginBase
+ {
+ _services = new ServiceCollection()
+ };
- IPluginRegister checksumRegister = new Register();
- IPluginRegister imagesRegister = new DiscImages.Register();
+ IPluginRegister imagesRegister = new Register();
IPluginRegister filesystemsRegister = new Aaru.Filesystems.Register();
IPluginRegister filtersRegister = new Filters.Register();
IPluginRegister partitionsRegister = new Aaru.Partitions.Register();
IPluginRegister archiveRegister = new Archives.Register();
- _instance.AddPlugins(checksumRegister);
+ _instance.AddPlugins(new Checksums.Register());
_instance.AddPlugins(imagesRegister);
_instance.AddPlugins(filesystemsRegister);
_instance.AddPlugins(filtersRegister);
_instance.AddPlugins(partitionsRegister);
_instance.AddPlugins(archiveRegister);
+ _instance._serviceProvider = _instance._services.BuildServiceProvider();
+
return _instance;
}
}
@@ -110,6 +132,8 @@ public sealed class PluginBase
/// Plugin register
void AddPlugins(IPluginRegister pluginRegister)
{
+ pluginRegister.RegisterChecksumPlugins(_services);
+
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty())
{
if(Activator.CreateInstance(type) is IFilesystem plugin && !Filesystems.ContainsKey(plugin.Name.ToLower()))
diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj
index d3d4ac148..bbabb16a6 100644
--- a/Aaru.Devices/Aaru.Devices.csproj
+++ b/Aaru.Devices/Aaru.Devices.csproj
@@ -42,6 +42,7 @@
true
+
diff --git a/Aaru.Filesystems/Aaru.Filesystems.csproj b/Aaru.Filesystems/Aaru.Filesystems.csproj
index a985a3956..445131928 100644
--- a/Aaru.Filesystems/Aaru.Filesystems.csproj
+++ b/Aaru.Filesystems/Aaru.Filesystems.csproj
@@ -45,6 +45,7 @@
+
diff --git a/Aaru.Filters/Aaru.Filters.csproj b/Aaru.Filters/Aaru.Filters.csproj
index c770f70d7..824de2d69 100644
--- a/Aaru.Filters/Aaru.Filters.csproj
+++ b/Aaru.Filters/Aaru.Filters.csproj
@@ -58,6 +58,7 @@
+
diff --git a/Aaru.Generators/PluginRegisterGenerator.cs b/Aaru.Generators/PluginRegisterGenerator.cs
index 9defc1151..59d97eeea 100644
--- a/Aaru.Generators/PluginRegisterGenerator.cs
+++ b/Aaru.Generators/PluginRegisterGenerator.cs
@@ -100,6 +100,7 @@ public class PluginRegisterGenerator : ISourceGenerator
sb.AppendLine("using System;");
sb.AppendLine("using System.Collections.Generic;");
sb.AppendLine("using Aaru.CommonTypes.Interfaces;");
+ sb.AppendLine("using Microsoft.Extensions.DependencyInjection;");
sb.AppendLine();
sb.AppendLine($"namespace {@namespace};");
sb.AppendLine();
@@ -123,16 +124,14 @@ public class PluginRegisterGenerator : ISourceGenerator
if(checksums?.Count > 0)
{
- sb.AppendLine(" public List GetAllChecksumPlugins() => new()");
+ sb.AppendLine(" public void RegisterChecksumPlugins(IServiceCollection services)");
sb.AppendLine(" {");
-
foreach(string plugin in checksums)
- sb.AppendLine($" typeof({plugin}),");
-
- sb.AppendLine(" };");
+ sb.AppendLine($" services.AddTransient();");
+ sb.AppendLine(" }");
}
else
- sb.AppendLine(" public List GetAllChecksumPlugins() => null;");
+ sb.AppendLine(" public void RegisterChecksumPlugins(IServiceCollection services) {}");
sb.AppendLine();
diff --git a/Aaru.Partitions/Aaru.Partitions.csproj b/Aaru.Partitions/Aaru.Partitions.csproj
index e8b484af9..9ca210672 100644
--- a/Aaru.Partitions/Aaru.Partitions.csproj
+++ b/Aaru.Partitions/Aaru.Partitions.csproj
@@ -60,6 +60,7 @@
+
diff --git a/Aaru/Main.cs b/Aaru/Main.cs
index 5ca597bbb..8922d0a62 100644
--- a/Aaru/Main.cs
+++ b/Aaru/Main.cs
@@ -240,7 +240,6 @@ class MainClass
rootCommand.AddCommand(new ImageFamily());
rootCommand.AddCommand(new MediaFamily());
rootCommand.AddCommand(new ArchiveFamily());
-
rootCommand.AddCommand(new ConfigureCommand());
rootCommand.AddCommand(new FormatsCommand());
rootCommand.AddCommand(new ListEncodingsCommand());