mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Plugin system] Move partitions to dependency injection.
This commit is contained in:
@@ -71,9 +71,11 @@ public interface IPluginRegister
|
||||
/// <returns>List of media image plugins</returns>
|
||||
List<Type> GetAllMediaImagePlugins();
|
||||
|
||||
/// <summary>Gets all partition plugins</summary>
|
||||
/// <returns>List of partition plugins</returns>
|
||||
List<Type> GetAllPartitionPlugins();
|
||||
/// <summary>
|
||||
/// Registers all partition plugins in the provided service collection
|
||||
/// </summary>
|
||||
/// <param name="services">Service collection</param>
|
||||
void RegisterPartitionPlugins(IServiceCollection services);
|
||||
|
||||
/// <summary>Gets all read-only filesystem plugins</summary>
|
||||
/// <returns>List of read-only filesystem plugins</returns>
|
||||
|
||||
@@ -54,8 +54,7 @@ public class PluginRegister
|
||||
public readonly SortedDictionary<string, Type> FloppyImages;
|
||||
/// <summary>List of all media image plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> MediaImages;
|
||||
/// <summary>List of all partition plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> Partitions;
|
||||
|
||||
/// <summary>List of read-only filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> ReadOnlyFilesystems;
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
@@ -69,7 +68,6 @@ public class PluginRegister
|
||||
{
|
||||
Filesystems = new SortedDictionary<string, Type>();
|
||||
ReadOnlyFilesystems = new SortedDictionary<string, Type>();
|
||||
Partitions = new SortedDictionary<string, Type>();
|
||||
MediaImages = new SortedDictionary<string, Type>();
|
||||
WritableImages = new SortedDictionary<string, Type>();
|
||||
FloppyImages = new SortedDictionary<string, Type>();
|
||||
@@ -78,6 +76,19 @@ public class PluginRegister
|
||||
ByteAddressableImages = new SortedDictionary<string, Type>();
|
||||
}
|
||||
|
||||
/// <summary>List of all partition plugins</summary>
|
||||
public SortedDictionary<string, IPartition> Partitions
|
||||
{
|
||||
get
|
||||
{
|
||||
SortedDictionary<string, IPartition> partitions = new();
|
||||
foreach(IPartition plugin in _serviceProvider.GetServices<IPartition>())
|
||||
partitions.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
return partitions;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of filter plugins</summary>
|
||||
public SortedDictionary<string, IFilter> Filters
|
||||
{
|
||||
@@ -165,11 +176,7 @@ public class PluginRegister
|
||||
MediaImages.Add(plugin.Name.ToLower(), type);
|
||||
}
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
||||
{
|
||||
if(Activator.CreateInstance(type) is IPartition plugin && !Partitions.ContainsKey(plugin.Name.ToLower()))
|
||||
Partitions.Add(plugin.Name.ToLower(), type);
|
||||
}
|
||||
pluginRegister.RegisterPartitionPlugins(_services);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user