diff --git a/Interfaces/IPluginRegister.cs b/Interfaces/IPluginRegister.cs index 495a448..df6ca34 100644 --- a/Interfaces/IPluginRegister.cs +++ b/Interfaces/IPluginRegister.cs @@ -89,9 +89,11 @@ public interface IPluginRegister /// Service collection void RegisterReadOnlyFilesystemPlugins(IServiceCollection services); - /// Gets all writable floppy image plugins - /// List of writable floppy image plugins - List GetAllWritableFloppyImagePlugins(); + /// + /// Registers all writable floppy image plugins in the provided service collection + /// + /// Service collection + void RegisterWritableFloppyImagePlugins(IServiceCollection services); /// Gets all writable media image plugins /// List of writable media image plugins diff --git a/PluginRegister.cs b/PluginRegister.cs index aec986d..6e2f10c 100644 --- a/PluginRegister.cs +++ b/PluginRegister.cs @@ -47,8 +47,6 @@ public class PluginRegister /// List of byte addressable image plugins public readonly SortedDictionary ByteAddressableImages; - /// List of writable floppy image plugins - public readonly SortedDictionary WritableFloppyImages; /// List of writable media image plugins public readonly SortedDictionary WritableImages; IServiceProvider _serviceProvider; @@ -57,10 +55,22 @@ public class PluginRegister PluginRegister() { WritableImages = new SortedDictionary(); - WritableFloppyImages = new SortedDictionary(); ByteAddressableImages = new SortedDictionary(); } + /// List of writable floppy image plugins + public SortedDictionary WritableFloppyImages + { + get + { + SortedDictionary floppyImages = new(); + foreach(IWritableFloppyImage plugin in _serviceProvider.GetServices()) + floppyImages[plugin.Name.ToLower()] = plugin; + + return floppyImages; + } + } + /// List of floppy image plugins public SortedDictionary FloppyImages { @@ -210,13 +220,7 @@ public class PluginRegister pluginRegister.RegisterFloppyImagePlugins(_services); pluginRegister.RegisterMediaImagePlugins(_services); pluginRegister.RegisterPartitionPlugins(_services); - - foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty()) - { - if(Activator.CreateInstance(type) is IWritableFloppyImage plugin && - !WritableFloppyImages.ContainsKey(plugin.Name.ToLower())) - WritableFloppyImages.Add(plugin.Name.ToLower(), type); - } + pluginRegister.RegisterWritableFloppyImagePlugins(_services); foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty()) {