mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
[Plugin system] Move writable floppy images to dependency injection.
This commit is contained in:
@@ -89,9 +89,11 @@ public interface IPluginRegister
|
||||
/// <param name="services">Service collection</param>
|
||||
void RegisterReadOnlyFilesystemPlugins(IServiceCollection services);
|
||||
|
||||
/// <summary>Gets all writable floppy image plugins</summary>
|
||||
/// <returns>List of writable floppy image plugins</returns>
|
||||
List<Type> GetAllWritableFloppyImagePlugins();
|
||||
/// <summary>
|
||||
/// Registers all writable floppy image plugins in the provided service collection
|
||||
/// </summary>
|
||||
/// <param name="services">Service collection</param>
|
||||
void RegisterWritableFloppyImagePlugins(IServiceCollection services);
|
||||
|
||||
/// <summary>Gets all writable media image plugins</summary>
|
||||
/// <returns>List of writable media image plugins</returns>
|
||||
|
||||
@@ -47,8 +47,6 @@ public class PluginRegister
|
||||
/// <summary>List of byte addressable image plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> ByteAddressableImages;
|
||||
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> WritableFloppyImages;
|
||||
/// <summary>List of writable media image plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> WritableImages;
|
||||
IServiceProvider _serviceProvider;
|
||||
@@ -57,10 +55,22 @@ public class PluginRegister
|
||||
PluginRegister()
|
||||
{
|
||||
WritableImages = new SortedDictionary<string, Type>();
|
||||
WritableFloppyImages = new SortedDictionary<string, Type>();
|
||||
ByteAddressableImages = new SortedDictionary<string, Type>();
|
||||
}
|
||||
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
public SortedDictionary<string, IWritableFloppyImage> WritableFloppyImages
|
||||
{
|
||||
get
|
||||
{
|
||||
SortedDictionary<string, IWritableFloppyImage> floppyImages = new();
|
||||
foreach(IWritableFloppyImage plugin in _serviceProvider.GetServices<IWritableFloppyImage>())
|
||||
floppyImages[plugin.Name.ToLower()] = plugin;
|
||||
|
||||
return floppyImages;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of floppy image plugins</summary>
|
||||
public SortedDictionary<string, IFloppyImage> 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<Type>())
|
||||
{
|
||||
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<Type>())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user