From fb8ed168213da692d0cc2307f9186ce995913136 Mon Sep 17 00:00:00 2001 From: Darkstar Date: Fri, 5 Mar 2021 13:46:55 +0100 Subject: [PATCH] Add support for Archive plugins --- Interfaces/IPluginRegister.cs | 6 +++++- PluginBase.cs | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Interfaces/IPluginRegister.cs b/Interfaces/IPluginRegister.cs index 65ef7ab68..aa8d79935 100644 --- a/Interfaces/IPluginRegister.cs +++ b/Interfaces/IPluginRegister.cs @@ -78,5 +78,9 @@ namespace Aaru.CommonTypes.Interfaces /// Gets all writable media image plugins /// List of writable media image plugins List GetAllWritableImagePlugins(); + + /// Gets all archive plugins + /// List of archive plugins + List GetAllArchivePlugins(); } -} \ No newline at end of file +} diff --git a/PluginBase.cs b/PluginBase.cs index 1c2fc729b..c709ad2f7 100644 --- a/PluginBase.cs +++ b/PluginBase.cs @@ -64,6 +64,8 @@ namespace Aaru.CommonTypes public readonly SortedDictionary WritableFloppyImages; /// List of writable media image plugins public readonly SortedDictionary WritableImages; + /// List of all archive formats + public readonly SortedDictionary Archives; /// Initializes the plugins lists public PluginBase() @@ -77,6 +79,7 @@ namespace Aaru.CommonTypes Filters = new SortedDictionary(); FloppyImages = new SortedDictionary(); WritableFloppyImages = new SortedDictionary(); + Archives = new SortedDictionary(); } public void AddPlugins(IPluginRegister pluginRegister) @@ -133,6 +136,12 @@ namespace Aaru.CommonTypes {}) is IWritableImage plugin && !WritableImages.ContainsKey(plugin.Name.ToLower())) WritableImages.Add(plugin.Name.ToLower(), plugin); + + foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty()) + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] + {}) is IArchive plugin && + !Archives.ContainsKey(plugin.Name.ToLower())) + Archives.Add(plugin.Name.ToLower(), plugin); } } -} \ No newline at end of file +}