diff --git a/Interfaces/IPluginRegister.cs b/Interfaces/IPluginRegister.cs index aa9a1c769..495a448aa 100644 --- a/Interfaces/IPluginRegister.cs +++ b/Interfaces/IPluginRegister.cs @@ -65,9 +65,11 @@ public interface IPluginRegister /// Service collection void RegisterFilterPlugins(IServiceCollection services); - /// Gets all floppy image plugins - /// List of floppy image plugins - List GetAllFloppyImagePlugins(); + /// + /// Registers all floppy image plugins in the provided service collection + /// + /// Service collection + void RegisterFloppyImagePlugins(IServiceCollection services); /// /// Registers all media image plugins in the provided service collection diff --git a/PluginRegister.cs b/PluginRegister.cs index 96e172bef..aec986d16 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 floppy image plugins - public readonly SortedDictionary FloppyImages; /// List of writable floppy image plugins public readonly SortedDictionary WritableFloppyImages; /// List of writable media image plugins @@ -59,11 +57,23 @@ public class PluginRegister PluginRegister() { WritableImages = new SortedDictionary(); - FloppyImages = new SortedDictionary(); WritableFloppyImages = new SortedDictionary(); ByteAddressableImages = new SortedDictionary(); } + /// List of floppy image plugins + public SortedDictionary FloppyImages + { + get + { + SortedDictionary floppyImages = new(); + foreach(IFloppyImage plugin in _serviceProvider.GetServices()) + floppyImages[plugin.Name.ToLower()] = plugin; + + return floppyImages; + } + } + /// List of all media image plugins public SortedDictionary MediaImages { @@ -197,14 +207,7 @@ public class PluginRegister pluginRegister.RegisterFilesystemPlugins(_services); pluginRegister.RegisterFilterPlugins(_services); pluginRegister.RegisterReadOnlyFilesystemPlugins(_services); - - foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty()) - { - if(Activator.CreateInstance(type) is IFloppyImage plugin && - !FloppyImages.ContainsKey(plugin.Name.ToLower())) - FloppyImages.Add(plugin.Name.ToLower(), type); - } - + pluginRegister.RegisterFloppyImagePlugins(_services); pluginRegister.RegisterMediaImagePlugins(_services); pluginRegister.RegisterPartitionPlugins(_services);