mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Plugin system] Move byte addressable media images to dependency injection.
This commit is contained in:
Submodule Aaru.CommonTypes updated: 33da34f017...8cc6d3f18b
@@ -84,11 +84,11 @@ public static class ImageFormat
|
||||
return imageFormat;
|
||||
|
||||
// Check all but RAW plugin
|
||||
foreach(Type pluginType in plugins.ByteAddressableImages.Values)
|
||||
foreach(IByteAddressableImage imagePlugin in plugins.ByteAddressableImages.Values)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Activator.CreateInstance(pluginType) is not IByteAddressableImage imagePlugin)
|
||||
if(imagePlugin is null)
|
||||
continue;
|
||||
|
||||
if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||
|
||||
@@ -247,16 +247,16 @@ public class PluginRegisterGenerator : ISourceGenerator
|
||||
|
||||
if(byteAddressableImagePlugins?.Count > 0)
|
||||
{
|
||||
sb.AppendLine(" public List<Type> GetAllByteAddressablePlugins() => new()");
|
||||
sb.AppendLine(" public void RegisterByteAddressablePlugins(IServiceCollection services)");
|
||||
sb.AppendLine(" {");
|
||||
|
||||
foreach(string plugin in byteAddressableImagePlugins)
|
||||
sb.AppendLine($" typeof({plugin}),");
|
||||
sb.AppendLine($" services.AddTransient<IByteAddressableImage, {plugin}>();");
|
||||
|
||||
sb.AppendLine(" };");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
else
|
||||
sb.AppendLine(" public List<Type> GetAllByteAddressablePlugins() => null;");
|
||||
sb.AppendLine(" public void RegisterByteAddressablePlugins(IServiceCollection services) {}");
|
||||
|
||||
sb.AppendLine("}");
|
||||
|
||||
|
||||
@@ -607,7 +607,6 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
|
||||
var checkRaw = false;
|
||||
List<string> idPlugins;
|
||||
Type pluginType;
|
||||
PluginRegister plugins = PluginRegister.Singleton;
|
||||
|
||||
if(partitions.Count == 0)
|
||||
|
||||
@@ -243,13 +243,9 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
|
||||
string pluginName = idPlugins[j];
|
||||
|
||||
if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName,
|
||||
out Type pluginType))
|
||||
out IReadOnlyFilesystem fs))
|
||||
continue;
|
||||
|
||||
Assert.IsNotNull(pluginType, Localization.Could_not_instantiate_filesystem_plugin);
|
||||
|
||||
var fs = Activator.CreateInstance(pluginType) as IReadOnlyFilesystem;
|
||||
|
||||
Assert.IsNotNull(fs, string.Format(Localization.Could_not_instantiate_filesystem_0, pluginName));
|
||||
|
||||
ErrorNumber error = fs.Mount(image, partitions[i], null, null, null);
|
||||
|
||||
@@ -76,7 +76,6 @@ public abstract class FsExtractIssueTest
|
||||
if(idPlugins.Count == 0)
|
||||
continue;
|
||||
|
||||
Type pluginType;
|
||||
ErrorNumber error;
|
||||
|
||||
if(idPlugins.Count > 1)
|
||||
|
||||
@@ -311,7 +311,6 @@ sealed class ExtractFilesCommand : Command
|
||||
AaruConsole.WriteLine(UI.Filesystem_not_identified);
|
||||
else
|
||||
{
|
||||
Type pluginType;
|
||||
ErrorNumber error = ErrorNumber.InvalidArgument;
|
||||
|
||||
if(idPlugins.Count > 1)
|
||||
|
||||
@@ -284,7 +284,6 @@ sealed class LsCommand : Command
|
||||
AaruConsole.WriteLine(UI.Filesystem_not_identified);
|
||||
else
|
||||
{
|
||||
Type pluginType;
|
||||
ErrorNumber error = ErrorNumber.InvalidArgument;
|
||||
|
||||
if(idPlugins.Count > 1)
|
||||
|
||||
Reference in New Issue
Block a user