🎨Separate read-only filesystems from identify-only filesystem interfaces.

This commit is contained in:
2017-12-26 07:23:09 +00:00
parent 3bbb645556
commit 6aee3c9cb1
74 changed files with 206 additions and 3407 deletions

View File

@@ -59,6 +59,10 @@ namespace DiscImageChef.Core
/// List of all filesystem plugins
/// </summary>
public readonly SortedDictionary<string, IFilesystem> PluginsList;
/// <summary>
/// List of all filesystem plugins
/// </summary>
public readonly SortedDictionary<string, IReadOnlyFilesystem> ReadOnlyFilesystems;
/// <summary>
/// Initializes the plugins lists
@@ -66,12 +70,13 @@ namespace DiscImageChef.Core
public PluginBase()
{
PluginsList = new SortedDictionary<string, IFilesystem>();
ReadOnlyFilesystems = new SortedDictionary<string, IReadOnlyFilesystem>();
PartPluginsList = new SortedDictionary<string, IPartition>();
ImagePluginsList = new SortedDictionary<string, IMediaImage>();
Assembly assembly = Assembly.GetAssembly(typeof(IMediaImage));
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IMediaImage))))
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IMediaImage))).Where(t=>t.IsClass))
try
{
IMediaImage plugin = (IMediaImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
@@ -81,7 +86,7 @@ namespace DiscImageChef.Core
assembly = Assembly.GetAssembly(typeof(IPartition));
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition))))
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition))).Where(t=>t.IsClass))
try
{
IPartition plugin =
@@ -92,13 +97,24 @@ namespace DiscImageChef.Core
assembly = Assembly.GetAssembly(typeof(IFilesystem));
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))))
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))).Where(t=>t.IsClass))
try
{
IFilesystem plugin = (IFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
assembly = Assembly.GetAssembly(typeof(IReadOnlyFilesystem));
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IReadOnlyFilesystem))).Where(t=>t.IsClass))
try
{
IReadOnlyFilesystem plugin = (IReadOnlyFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterReadOnlyFilesystem(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
}
void RegisterImagePlugin(IMediaImage plugin)
@@ -112,6 +128,11 @@ namespace DiscImageChef.Core
if(!PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin);
}
void RegisterReadOnlyFilesystem(IReadOnlyFilesystem plugin)
{
if(!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower())) ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
}
void RegisterPartPlugin(IPartition partplugin)
{
if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower()))