From f5f9dc1ad4e155ed5514adc82e006ca3524e4825 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 17 Dec 2022 20:03:47 +0000 Subject: [PATCH] Use Type for byte addressable plugin list. --- Aaru.CommonTypes | 2 +- Aaru.Core/ImageFormat.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 29535b5b3..d603dca1a 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 29535b5b360f1440e9f8554c7488fb929a214ad1 +Subproject commit d603dca1ad8f1ab82243dba982e7d3244b8f1259 diff --git a/Aaru.Core/ImageFormat.cs b/Aaru.Core/ImageFormat.cs index 8abdf9bc7..7bf88d868 100644 --- a/Aaru.Core/ImageFormat.cs +++ b/Aaru.Core/ImageFormat.cs @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Console; @@ -83,10 +82,16 @@ public static class ImageFormat return imageFormat; // Check all but RAW plugin - foreach(IByteAddressableImage imagePlugin in plugins.ByteAddressableImages.Values.Where(imagePlugin => - imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) + foreach(Type pluginType in plugins.ByteAddressableImages.Values) + { try { + if(Activator.CreateInstance(pluginType) is not IByteAddressableImage imagePlugin) + continue; + + if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) + continue; + AaruConsole.DebugWriteLine("Format detection", Localization.Core.Trying_plugin_0, imagePlugin.Name); if(!imagePlugin.Identify(imageFilter)) @@ -101,6 +106,7 @@ public static class ImageFormat { // ignored } + } if(imageFormat != null) return imageFormat;