mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Type for partition plugin list.
This commit is contained in:
Submodule Aaru.CommonTypes updated: 1e0ba4d3ac...679d36b353
@@ -30,6 +30,7 @@
|
|||||||
// Copyright © 2011-2023 Natalia Portillo
|
// Copyright © 2011-2023 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
@@ -59,14 +60,19 @@ public static class Partitions
|
|||||||
if(tapeImage?.Files != null)
|
if(tapeImage?.Files != null)
|
||||||
foreach(TapeFile tapeFile in tapeImage.Files)
|
foreach(TapeFile tapeFile in tapeImage.Files)
|
||||||
{
|
{
|
||||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
foreach(Type pluginType in plugins.Partitions.Values)
|
||||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, tapeFile.FirstBlock))
|
{
|
||||||
{
|
if(Activator.CreateInstance(pluginType) is not IPartition part)
|
||||||
foundPartitions.AddRange(partitions);
|
continue;
|
||||||
|
|
||||||
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, partitionPlugin.Name,
|
if(!part.GetInformation(image, out List<Partition> partitions, tapeFile.FirstBlock))
|
||||||
tapeFile.FirstBlock);
|
continue;
|
||||||
}
|
|
||||||
|
foundPartitions.AddRange(partitions);
|
||||||
|
|
||||||
|
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, part.Name,
|
||||||
|
tapeFile.FirstBlock);
|
||||||
|
}
|
||||||
|
|
||||||
checkedLocations.Add(tapeFile.FirstBlock);
|
checkedLocations.Add(tapeFile.FirstBlock);
|
||||||
}
|
}
|
||||||
@@ -75,14 +81,19 @@ public static class Partitions
|
|||||||
if(partitionableImage?.Partitions != null)
|
if(partitionableImage?.Partitions != null)
|
||||||
foreach(Partition imagePartition in partitionableImage.Partitions)
|
foreach(Partition imagePartition in partitionableImage.Partitions)
|
||||||
{
|
{
|
||||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
foreach(Type pluginType in plugins.Partitions.Values)
|
||||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
|
{
|
||||||
{
|
if(Activator.CreateInstance(pluginType) is not IPartition part)
|
||||||
foundPartitions.AddRange(partitions);
|
continue;
|
||||||
|
|
||||||
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, partitionPlugin.Name,
|
if(!part.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
|
||||||
imagePartition.Start);
|
continue;
|
||||||
}
|
|
||||||
|
foundPartitions.AddRange(partitions);
|
||||||
|
|
||||||
|
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, part.Name,
|
||||||
|
imagePartition.Start);
|
||||||
|
}
|
||||||
|
|
||||||
checkedLocations.Add(imagePartition.Start);
|
checkedLocations.Add(imagePartition.Start);
|
||||||
}
|
}
|
||||||
@@ -90,12 +101,17 @@ public static class Partitions
|
|||||||
// Getting all partitions at start of device
|
// Getting all partitions at start of device
|
||||||
if(!checkedLocations.Contains(0))
|
if(!checkedLocations.Contains(0))
|
||||||
{
|
{
|
||||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
foreach(Type pluginType in plugins.Partitions.Values)
|
||||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, 0))
|
{
|
||||||
{
|
if(Activator.CreateInstance(pluginType) is not IPartition part)
|
||||||
foundPartitions.AddRange(partitions);
|
continue;
|
||||||
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_zero, partitionPlugin.Name);
|
|
||||||
}
|
if(!part.GetInformation(image, out List<Partition> partitions, 0))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foundPartitions.AddRange(partitions);
|
||||||
|
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_zero, part.Name);
|
||||||
|
}
|
||||||
|
|
||||||
checkedLocations.Add(0);
|
checkedLocations.Add(0);
|
||||||
}
|
}
|
||||||
@@ -112,15 +128,18 @@ public static class Partitions
|
|||||||
|
|
||||||
List<Partition> children = new();
|
List<Partition> children = new();
|
||||||
|
|
||||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
foreach(Type pluginType in plugins.Partitions.Values)
|
||||||
{
|
{
|
||||||
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Trying_0_at_1, partitionPlugin.Name,
|
if(Activator.CreateInstance(pluginType) is not IPartition part)
|
||||||
foundPartitions[0].Start);
|
|
||||||
|
|
||||||
if(!partitionPlugin.GetInformation(image, out List<Partition> partitions, foundPartitions[0].Start))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, partitionPlugin.Name,
|
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Trying_0_at_1, part.Name,
|
||||||
|
foundPartitions[0].Start);
|
||||||
|
|
||||||
|
if(!part.GetInformation(image, out List<Partition> partitions, foundPartitions[0].Start))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
AaruConsole.DebugWriteLine("Partitions", Localization.Core.Found_0_at_1, part.Name,
|
||||||
foundPartitions[0].Start);
|
foundPartitions[0].Start);
|
||||||
|
|
||||||
children.AddRange(partitions);
|
children.AddRange(partitions);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
// Copyright © 2011-2023 Natalia Portillo
|
// Copyright © 2011-2023 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -88,32 +89,47 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
Author = mediaImage.Author
|
Author = mediaImage.Author
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach(IPartition partition in GetPluginBase.Instance.PartPluginsList.Values)
|
foreach(Type partitionType in GetPluginBase.Instance.Partitions.Values)
|
||||||
|
{
|
||||||
|
if(Activator.CreateInstance(partitionType) is not IPartition partition)
|
||||||
|
continue;
|
||||||
|
|
||||||
PartitionSchemes.Add(new PluginModel
|
PartitionSchemes.Add(new PluginModel
|
||||||
{
|
{
|
||||||
Name = partition.Name,
|
Name = partition.Name,
|
||||||
Uuid = partition.Id,
|
Uuid = partition.Id,
|
||||||
Version = Assembly.GetAssembly(partition.GetType())?.GetName().Version?.ToString(),
|
Version = Assembly.GetAssembly(partitionType)?.GetName().Version?.ToString(),
|
||||||
Author = partition.Author
|
Author = partition.Author
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(Type filesystem in GetPluginBase.Instance.Filesystems.Values)
|
||||||
|
{
|
||||||
|
if(Activator.CreateInstance(filesystem) is not IFilesystem fs)
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach(IFilesystem filesystem in GetPluginBase.Instance.Filesystems.Values)
|
|
||||||
Filesystems.Add(new PluginModel
|
Filesystems.Add(new PluginModel
|
||||||
{
|
{
|
||||||
Name = filesystem.Name,
|
Name = fs.Name,
|
||||||
Uuid = filesystem.Id,
|
Uuid = fs.Id,
|
||||||
Version = Assembly.GetAssembly(filesystem.GetType())?.GetName().Version?.ToString(),
|
Version = Assembly.GetAssembly(filesystem)?.GetName().Version?.ToString(),
|
||||||
Author = filesystem.Author
|
Author = fs.Author
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(Type readOnlyFilesystem in GetPluginBase.Instance.ReadOnlyFilesystems.Values)
|
||||||
|
{
|
||||||
|
if(Activator.CreateInstance(readOnlyFilesystem) is not IReadOnlyFilesystem fs)
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach(IReadOnlyFilesystem readOnlyFilesystem in GetPluginBase.Instance.ReadOnlyFilesystems.Values)
|
|
||||||
ReadOnlyFilesystems.Add(new PluginModel
|
ReadOnlyFilesystems.Add(new PluginModel
|
||||||
{
|
{
|
||||||
Name = readOnlyFilesystem.Name,
|
Name = fs.Name,
|
||||||
Uuid = readOnlyFilesystem.Id,
|
Uuid = fs.Id,
|
||||||
Version = Assembly.GetAssembly(readOnlyFilesystem.GetType())?.GetName().Version?.ToString(),
|
Version = Assembly.GetAssembly(readOnlyFilesystem)?.GetName().Version?.ToString(),
|
||||||
Author = readOnlyFilesystem.Author
|
Author = fs.Author
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
foreach(IWritableFloppyImage writableFloppyImage in GetPluginBase.Instance.WritableFloppyImages.Values)
|
foreach(IWritableFloppyImage writableFloppyImage in GetPluginBase.Instance.WritableFloppyImages.Values)
|
||||||
WritableFloppyImages.Add(new PluginModel
|
WritableFloppyImages.Add(new PluginModel
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ sealed class FormatsCommand : Command
|
|||||||
|
|
||||||
table = new Table
|
table = new Table
|
||||||
{
|
{
|
||||||
Title = new TableTitle(string.Format(UI.Supported_partitioning_schemes_0, plugins.PartPluginsList.Count))
|
Title = new TableTitle(string.Format(UI.Supported_partitioning_schemes_0, plugins.Partitions.Count))
|
||||||
};
|
};
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
@@ -217,11 +217,16 @@ sealed class FormatsCommand : Command
|
|||||||
|
|
||||||
table.AddColumn(UI.Title_Scheme);
|
table.AddColumn(UI.Title_Scheme);
|
||||||
|
|
||||||
foreach(KeyValuePair<string, IPartition> kvp in plugins.PartPluginsList)
|
foreach(KeyValuePair<string, Type> kvp in plugins.Partitions)
|
||||||
|
{
|
||||||
|
if(Activator.CreateInstance(kvp.Value) is not IPartition part)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(verbose)
|
if(verbose)
|
||||||
table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name));
|
table.AddRow(part.Id.ToString(), Markup.Escape(part.Name));
|
||||||
else
|
else
|
||||||
table.AddRow(Markup.Escape(kvp.Value.Name));
|
table.AddRow(Markup.Escape(part.Name));
|
||||||
|
}
|
||||||
|
|
||||||
AnsiConsole.Write(table);
|
AnsiConsole.Write(table);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user