diff --git a/Interfaces/IPluginRegister.cs b/Interfaces/IPluginRegister.cs index 67c12d187..e68fa0d20 100644 --- a/Interfaces/IPluginRegister.cs +++ b/Interfaces/IPluginRegister.cs @@ -79,9 +79,11 @@ public interface IPluginRegister /// Service collection void RegisterPartitionPlugins(IServiceCollection services); - /// Gets all read-only filesystem plugins - /// List of read-only filesystem plugins - List GetAllReadOnlyFilesystemPlugins(); + /// + /// Registers all read-only filesystem plugins in the provided service collection + /// + /// Service collection + void RegisterReadOnlyFilesystemPlugins(IServiceCollection services); /// Gets all writable floppy image plugins /// List of writable floppy image plugins diff --git a/PluginRegister.cs b/PluginRegister.cs index 7c899de0a..ca47f9068 100644 --- a/PluginRegister.cs +++ b/PluginRegister.cs @@ -51,9 +51,6 @@ public class PluginRegister public readonly SortedDictionary FloppyImages; /// List of all media image plugins public readonly SortedDictionary MediaImages; - - /// List of read-only filesystem plugins - public readonly SortedDictionary ReadOnlyFilesystems; /// List of writable floppy image plugins public readonly SortedDictionary WritableFloppyImages; /// List of writable media image plugins @@ -63,7 +60,6 @@ public class PluginRegister PluginRegister() { - ReadOnlyFilesystems = new SortedDictionary(); MediaImages = new SortedDictionary(); WritableImages = new SortedDictionary(); FloppyImages = new SortedDictionary(); @@ -71,6 +67,19 @@ public class PluginRegister ByteAddressableImages = new SortedDictionary(); } + /// List of read-only filesystem plugins + public SortedDictionary ReadOnlyFilesystems + { + get + { + SortedDictionary readOnlyFilesystems = new(); + foreach(IReadOnlyFilesystem plugin in _serviceProvider.GetServices()) + readOnlyFilesystems[plugin.Name.ToLower()] = plugin; + + return readOnlyFilesystems; + } + } + /// List of all filesystem plugins public SortedDictionary Filesystems { @@ -177,6 +186,7 @@ public class PluginRegister pluginRegister.RegisterChecksumPlugins(_services); pluginRegister.RegisterFilesystemPlugins(_services); pluginRegister.RegisterFilterPlugins(_services); + pluginRegister.RegisterReadOnlyFilesystemPlugins(_services); foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty()) { @@ -193,13 +203,6 @@ public class PluginRegister pluginRegister.RegisterPartitionPlugins(_services); - foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty()) - { - if(Activator.CreateInstance(type) is IReadOnlyFilesystem plugin && - !ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower())) - ReadOnlyFilesystems.Add(plugin.Name.ToLower(), type); - } - foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty()) { if(Activator.CreateInstance(type) is IWritableFloppyImage plugin &&