mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Activator in PluginBase.
This commit is contained in:
@@ -33,8 +33,8 @@
|
||||
<NoWarn>CS1591;CS1574</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<InternalsVisibleTo Include="Aaru.Tests" />
|
||||
<InternalsVisibleTo Include="Aaru.Tests.Devices" />
|
||||
<InternalsVisibleTo Include="Aaru.Tests"/>
|
||||
<InternalsVisibleTo Include="Aaru.Tests.Devices"/>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
|
||||
@@ -42,12 +42,12 @@
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7" />
|
||||
<PackageReference Include="System.Security.Principal.Windows" Version="6.0.0-preview.5.21301.5" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.1" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0"/>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7"/>
|
||||
<PackageReference Include="System.Security.Principal.Windows" Version="6.0.0-preview.5.21301.5"/>
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.1"/>
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0"/>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\LICENSE.MIT">
|
||||
@@ -55,9 +55,9 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Localization\Aaru.Localization.csproj" />
|
||||
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
|
||||
<ProjectReference Include="..\Aaru.Localization\Aaru.Localization.csproj"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Localization\Localization.resx">
|
||||
|
||||
@@ -52,6 +52,8 @@ public class PluginBase
|
||||
public readonly SortedDictionary<string, IByteAddressableImage> ByteAddressableImages;
|
||||
/// <summary>List of checksum plugins</summary>
|
||||
public readonly List<IChecksum> Checksums;
|
||||
/// <summary>List of all filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> Filesystems;
|
||||
/// <summary>List of filter plugins</summary>
|
||||
public readonly SortedDictionary<string, IFilter> Filters;
|
||||
/// <summary>List of floppy image plugins</summary>
|
||||
@@ -60,8 +62,6 @@ public class PluginBase
|
||||
public readonly SortedDictionary<string, IMediaImage> ImagePluginsList;
|
||||
/// <summary>List of all partition plugins</summary>
|
||||
public readonly SortedDictionary<string, IPartition> PartPluginsList;
|
||||
/// <summary>List of all filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> Filesystems;
|
||||
/// <summary>List of read-only filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, Type> ReadOnlyFilesystems;
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
@@ -90,56 +90,56 @@ public class PluginBase
|
||||
public void AddPlugins(IPluginRegister pluginRegister)
|
||||
{
|
||||
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IChecksum plugin)
|
||||
if(Activator.CreateInstance(type) is IChecksum plugin)
|
||||
Checksums.Add(plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFilesystem plugin &&
|
||||
if(Activator.CreateInstance(type) is IFilesystem plugin &&
|
||||
!Filesystems.ContainsKey(plugin.Name.ToLower()))
|
||||
Filesystems.Add(plugin.Name.ToLower(), plugin.GetType());
|
||||
Filesystems.Add(plugin.Name.ToLower(), type);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFilter plugin &&
|
||||
if(Activator.CreateInstance(type) is IFilter plugin &&
|
||||
!Filters.ContainsKey(plugin.Name.ToLower()))
|
||||
Filters.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFloppyImage plugin &&
|
||||
if(Activator.CreateInstance(type) is IFloppyImage plugin &&
|
||||
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
FloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IMediaImage plugin &&
|
||||
if(Activator.CreateInstance(type) is IMediaImage plugin &&
|
||||
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IPartition plugin &&
|
||||
if(Activator.CreateInstance(type) is IPartition plugin &&
|
||||
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IReadOnlyFilesystem plugin &&
|
||||
if(Activator.CreateInstance(type) is IReadOnlyFilesystem plugin &&
|
||||
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin.GetType());
|
||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), type);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IWritableFloppyImage plugin &&
|
||||
if(Activator.CreateInstance(type) is IWritableFloppyImage plugin &&
|
||||
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IBaseWritableImage plugin &&
|
||||
if(Activator.CreateInstance(type) is IBaseWritableImage plugin &&
|
||||
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IArchive plugin &&
|
||||
if(Activator.CreateInstance(type) is IArchive plugin &&
|
||||
!Archives.ContainsKey(plugin.Name.ToLower()))
|
||||
Archives.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllByteAddressablePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IByteAddressableImage plugin &&
|
||||
if(Activator.CreateInstance(type) is IByteAddressableImage plugin &&
|
||||
!ByteAddressableImages.ContainsKey(plugin.Name.ToLower()))
|
||||
ByteAddressableImages.Add(plugin.Name.ToLower(), plugin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user