mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Register byte addressable plugins.
This commit is contained in:
@@ -39,8 +39,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.CommonTypes.Interfaces
|
||||
{
|
||||
namespace Aaru.CommonTypes.Interfaces;
|
||||
|
||||
/// <summary>Defines a register of all known plugins</summary>
|
||||
public interface IPluginRegister
|
||||
{
|
||||
@@ -83,5 +83,8 @@ namespace Aaru.CommonTypes.Interfaces
|
||||
/// <summary>Gets all archive plugins</summary>
|
||||
/// <returns>List of archive plugins</returns>
|
||||
List<Type> GetAllArchivePlugins();
|
||||
}
|
||||
|
||||
/// <summary>Gets all byte addressable plugins</summary>
|
||||
/// <returns>List of byte addressable plugins</returns>
|
||||
List<Type> GetAllByteAddressablePlugins();
|
||||
}
|
||||
@@ -41,13 +41,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
{
|
||||
namespace Aaru.CommonTypes;
|
||||
|
||||
/// <summary>Contain all plugins (filesystem, partition and image)</summary>
|
||||
public class PluginBase
|
||||
{
|
||||
/// <summary>List of all archive formats</summary>
|
||||
public readonly SortedDictionary<string, IArchive> Archives;
|
||||
/// <summary>List of byte addressable image plugins</summary>
|
||||
public readonly SortedDictionary<string, IByteAddressableImage> ByteAddressableImages;
|
||||
/// <summary>List of checksum plugins</summary>
|
||||
public readonly List<IChecksum> Checksums;
|
||||
/// <summary>List of filter plugins</summary>
|
||||
@@ -80,6 +82,7 @@ namespace Aaru.CommonTypes
|
||||
FloppyImages = new SortedDictionary<string, IFloppyImage>();
|
||||
WritableFloppyImages = new SortedDictionary<string, IWritableFloppyImage>();
|
||||
Archives = new SortedDictionary<string, IArchive>();
|
||||
ByteAddressableImages = new SortedDictionary<string, IByteAddressableImage>();
|
||||
}
|
||||
|
||||
/// <summary>Adds plugins to the central plugin register</summary>
|
||||
@@ -144,6 +147,11 @@ namespace Aaru.CommonTypes
|
||||
{}) is IArchive plugin &&
|
||||
!Archives.ContainsKey(plugin.Name.ToLower()))
|
||||
Archives.Add(plugin.Name.ToLower(), plugin);
|
||||
}
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{}) is IByteAddressableImage plugin &&
|
||||
!ByteAddressableImages.ContainsKey(plugin.Name.ToLower()))
|
||||
ByteAddressableImages.Add(plugin.Name.ToLower(), plugin);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user