mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Plugin system] Move filesystems to dependency injection.
This commit is contained in:
@@ -53,9 +53,11 @@ public interface IPluginRegister
|
|||||||
/// <param name="services">Service collection</param>
|
/// <param name="services">Service collection</param>
|
||||||
void RegisterChecksumPlugins(IServiceCollection services);
|
void RegisterChecksumPlugins(IServiceCollection services);
|
||||||
|
|
||||||
/// <summary>Gets all filesystem plugins</summary>
|
/// <summary>
|
||||||
/// <returns>List of filesystem plugins</returns>
|
/// Registers all filesystem plugins in the provided service collection
|
||||||
List<Type> GetAllFilesystemPlugins();
|
/// </summary>
|
||||||
|
/// <param name="services">Service collection</param>
|
||||||
|
void RegisterFilesystemPlugins(IServiceCollection services);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers all filter plugins in the provided service collection
|
/// Registers all filter plugins in the provided service collection
|
||||||
|
|||||||
@@ -46,8 +46,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 all filesystem plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> Filesystems;
|
|
||||||
|
|
||||||
/// <summary>List of floppy image plugins</summary>
|
/// <summary>List of floppy image plugins</summary>
|
||||||
public readonly SortedDictionary<string, Type> FloppyImages;
|
public readonly SortedDictionary<string, Type> FloppyImages;
|
||||||
@@ -65,7 +63,6 @@ public class PluginRegister
|
|||||||
|
|
||||||
PluginRegister()
|
PluginRegister()
|
||||||
{
|
{
|
||||||
Filesystems = new SortedDictionary<string, Type>();
|
|
||||||
ReadOnlyFilesystems = new SortedDictionary<string, Type>();
|
ReadOnlyFilesystems = new SortedDictionary<string, Type>();
|
||||||
MediaImages = new SortedDictionary<string, Type>();
|
MediaImages = new SortedDictionary<string, Type>();
|
||||||
WritableImages = new SortedDictionary<string, Type>();
|
WritableImages = new SortedDictionary<string, Type>();
|
||||||
@@ -74,6 +71,19 @@ public class PluginRegister
|
|||||||
ByteAddressableImages = new SortedDictionary<string, Type>();
|
ByteAddressableImages = new SortedDictionary<string, Type>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>List of all filesystem plugins</summary>
|
||||||
|
public SortedDictionary<string, IFilesystem> Filesystems
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
SortedDictionary<string, IFilesystem> filesystems = new();
|
||||||
|
foreach(IFilesystem plugin in _serviceProvider.GetServices<IFilesystem>())
|
||||||
|
filesystems[plugin.Name.ToLower()] = plugin;
|
||||||
|
|
||||||
|
return filesystems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>List of all archive formats</summary>
|
/// <summary>List of all archive formats</summary>
|
||||||
public SortedDictionary<string, IArchive> Archives
|
public SortedDictionary<string, IArchive> Archives
|
||||||
{
|
{
|
||||||
@@ -81,7 +91,7 @@ public class PluginRegister
|
|||||||
{
|
{
|
||||||
SortedDictionary<string, IArchive> archives = new();
|
SortedDictionary<string, IArchive> archives = new();
|
||||||
foreach(IArchive plugin in _serviceProvider.GetServices<IArchive>())
|
foreach(IArchive plugin in _serviceProvider.GetServices<IArchive>())
|
||||||
archives.Add(plugin.Name.ToLower(), plugin);
|
archives[plugin.Name.ToLower()] = plugin;
|
||||||
|
|
||||||
return archives;
|
return archives;
|
||||||
}
|
}
|
||||||
@@ -94,7 +104,7 @@ public class PluginRegister
|
|||||||
{
|
{
|
||||||
SortedDictionary<string, IPartition> partitions = new();
|
SortedDictionary<string, IPartition> partitions = new();
|
||||||
foreach(IPartition plugin in _serviceProvider.GetServices<IPartition>())
|
foreach(IPartition plugin in _serviceProvider.GetServices<IPartition>())
|
||||||
partitions.Add(plugin.Name.ToLower(), plugin);
|
partitions[plugin.Name.ToLower()] = plugin;
|
||||||
|
|
||||||
return partitions;
|
return partitions;
|
||||||
}
|
}
|
||||||
@@ -107,7 +117,7 @@ public class PluginRegister
|
|||||||
{
|
{
|
||||||
SortedDictionary<string, IFilter> filters = new();
|
SortedDictionary<string, IFilter> filters = new();
|
||||||
foreach(IFilter plugin in _serviceProvider.GetServices<IFilter>())
|
foreach(IFilter plugin in _serviceProvider.GetServices<IFilter>())
|
||||||
filters.Add(plugin.Name.ToLower(), plugin);
|
filters[plugin.Name.ToLower()] = plugin;
|
||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
@@ -120,7 +130,7 @@ public class PluginRegister
|
|||||||
{
|
{
|
||||||
SortedDictionary<string, IChecksum> checksums = new();
|
SortedDictionary<string, IChecksum> checksums = new();
|
||||||
foreach(IChecksum plugin in _serviceProvider.GetServices<IChecksum>())
|
foreach(IChecksum plugin in _serviceProvider.GetServices<IChecksum>())
|
||||||
checksums.Add(plugin.Name.ToLower(), plugin);
|
checksums[plugin.Name.ToLower()] = plugin;
|
||||||
|
|
||||||
return checksums;
|
return checksums;
|
||||||
}
|
}
|
||||||
@@ -165,13 +175,7 @@ public class PluginRegister
|
|||||||
void AddPlugins(IPluginRegister pluginRegister)
|
void AddPlugins(IPluginRegister pluginRegister)
|
||||||
{
|
{
|
||||||
pluginRegister.RegisterChecksumPlugins(_services);
|
pluginRegister.RegisterChecksumPlugins(_services);
|
||||||
|
pluginRegister.RegisterFilesystemPlugins(_services);
|
||||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IFilesystem plugin && !Filesystems.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
Filesystems.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginRegister.RegisterFilterPlugins(_services);
|
pluginRegister.RegisterFilterPlugins(_services);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
|
|||||||
Reference in New Issue
Block a user