mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +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>
|
/// <param name="services">Service collection</param>
|
||||||
void RegisterReadOnlyFilesystemPlugins(IServiceCollection services);
|
void RegisterReadOnlyFilesystemPlugins(IServiceCollection services);
|
||||||
|
|
||||||
/// <summary>Gets all writable floppy image plugins</summary>
|
/// <summary>
|
||||||
/// <returns>List of writable floppy image plugins</returns>
|
/// Registers all writable floppy image plugins in the provided service collection
|
||||||
List<Type> GetAllWritableFloppyImagePlugins();
|
/// </summary>
|
||||||
|
/// <param name="services">Service collection</param>
|
||||||
|
void RegisterWritableFloppyImagePlugins(IServiceCollection services);
|
||||||
|
|
||||||
/// <summary>Gets all writable media image plugins</summary>
|
/// <summary>Gets all writable media image plugins</summary>
|
||||||
/// <returns>List of writable media image plugins</returns>
|
/// <returns>List of writable media image plugins</returns>
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ public class PluginRegister
|
|||||||
/// <summary>List of byte addressable image plugins</summary>
|
/// <summary>List of byte addressable image plugins</summary>
|
||||||
public readonly SortedDictionary<string, Type> ByteAddressableImages;
|
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>
|
/// <summary>List of writable media image plugins</summary>
|
||||||
public readonly SortedDictionary<string, Type> WritableImages;
|
public readonly SortedDictionary<string, Type> WritableImages;
|
||||||
IServiceProvider _serviceProvider;
|
IServiceProvider _serviceProvider;
|
||||||
@@ -57,10 +55,22 @@ public class PluginRegister
|
|||||||
PluginRegister()
|
PluginRegister()
|
||||||
{
|
{
|
||||||
WritableImages = new SortedDictionary<string, Type>();
|
WritableImages = new SortedDictionary<string, Type>();
|
||||||
WritableFloppyImages = new SortedDictionary<string, Type>();
|
|
||||||
ByteAddressableImages = 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>
|
/// <summary>List of floppy image plugins</summary>
|
||||||
public SortedDictionary<string, IFloppyImage> FloppyImages
|
public SortedDictionary<string, IFloppyImage> FloppyImages
|
||||||
{
|
{
|
||||||
@@ -210,13 +220,7 @@ public class PluginRegister
|
|||||||
pluginRegister.RegisterFloppyImagePlugins(_services);
|
pluginRegister.RegisterFloppyImagePlugins(_services);
|
||||||
pluginRegister.RegisterMediaImagePlugins(_services);
|
pluginRegister.RegisterMediaImagePlugins(_services);
|
||||||
pluginRegister.RegisterPartitionPlugins(_services);
|
pluginRegister.RegisterPartitionPlugins(_services);
|
||||||
|
pluginRegister.RegisterWritableFloppyImagePlugins(_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user